Bug 1414894 - [tryselect] Don't install shell extensions when bootstrapping fzf for |mach try fuzzy|, r?armenzg
Currently the prompts don't make it clear enough that running fzf will mess with your
shell settings. This means users could install it without realizing, forget and get
confused later on.
Rather than try to address this, it's simpler to always skip the shell extensions as
|mach try fuzzy| doesn't need them anyway. The extensions are useful, but are better
installed via something like |mach bootstrap| which can be tackled in a separate bug.
MozReview-Commit-ID: 2kx7UGO5LJ0
--- a/tools/tryselect/selectors/fuzzy.py
+++ b/tools/tryselect/selectors/fuzzy.py
@@ -47,23 +47,16 @@ platform:
https://github.com/junegunn/fzf#installation
Only the binary is required, if you do not wish to install the shell and
editor integrations, download the appropriate binary and put it on your $PATH:
https://github.com/junegunn/fzf-bin/releases
""".lstrip()
-FZF_RUN_INSTALL_WIZARD = """
-{t.bold}Running the fzf installation wizard.{t.normal}
-
-Only the fzf binary is required, if you do not wish to install the shell
-integrations, {t.bold}feel free to press 'n' at each of the prompts.{t.normal}
-""".format(t=terminal)
-
FZF_HEADER = """
For more shortcuts, see {t.italic_white}mach help try fuzzy{t.normal} and {t.italic_white}man fzf
{shortcuts}
""".strip()
fzf_shortcuts = {
'ctrl-a': 'select-all',
'ctrl-d': 'deselect-all',
@@ -111,28 +104,21 @@ class FuzzyParser(BaseTryParser):
templates = ['artifact', 'env']
def run(cmd, cwd=None):
is_win = platform.system() == 'Windows'
return subprocess.call(cmd, cwd=cwd, shell=True if is_win else False)
-def run_fzf_install_script(fzf_path, bin_only=False):
- # We could run this without installing the shell integrations on all
- # platforms, but those integrations are actually really useful so give user
- # the choice.
+def run_fzf_install_script(fzf_path):
if platform.system() == 'Windows':
cmd = ['bash', '-c', './install --bin']
else:
- cmd = ['./install']
- if bin_only:
- cmd.append('--bin')
- else:
- print(FZF_RUN_INSTALL_WIZARD)
+ cmd = ['./install', '--bin']
if run(cmd, cwd=fzf_path):
print(FZF_INSTALL_FAILED)
sys.exit(1)
def fzf_bootstrap(update=False):
"""Bootstrap fzf if necessary and return path to the executable.
@@ -154,17 +140,17 @@ def fzf_bootstrap(update=False):
return find_executable('fzf', os.path.join(fzf_path, 'bin'))
if update:
ret = run(['git', 'pull'], cwd=fzf_path)
if ret:
print("Update fzf failed.")
sys.exit(1)
- run_fzf_install_script(fzf_path, bin_only=True)
+ run_fzf_install_script(fzf_path)
return get_fzf()
if os.path.isdir(fzf_path):
fzf_bin = get_fzf()
if fzf_bin:
return fzf_bin
# Fzf is cloned, but binary doesn't exist. Try running the install script
return fzf_bootstrap(update=True)