From d5097a5e971c46912188a9004b2289cff3798221 Mon Sep 17 00:00:00 2001 From: yassin <135610141+achengli@users.noreply.github.com> Date: Sun, 18 Aug 2024 01:45:50 +0200 Subject: [PATCH] Performance issue with fish shell (#1483) The fish shell takes a long time to open an instance, this is because an instance of Brew is running to initialize packages when it is certainly not required to activate it, for example, open a simple terminal to edit some file Co-authored-by: achengli --- .../usr/share/fish/vendor_conf.d/brew.fish | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/system_files/overrides/usr/share/fish/vendor_conf.d/brew.fish b/system_files/overrides/usr/share/fish/vendor_conf.d/brew.fish index 1ddb1c68..c0d51f0f 100644 --- a/system_files/overrides/usr/share/fish/vendor_conf.d/brew.fish +++ b/system_files/overrides/usr/share/fish/vendor_conf.d/brew.fish @@ -1,18 +1,32 @@ #!/usr/bin/fish #shellcheck disable=all -if status --is-interactive - if [ -d /home/linuxbrew/.linuxbrew ] +set -g __brew_instance_initialize 0 +set -g __brew_binary /home/linuxbrew/.linuxbrew/bin/brew + +function brew_new_instance + alias brew=$__brew_binary + if test $__brew_instance_initialize = 0 + if status --is-interactive + if [ -d /home/linuxbrew/.linuxbrew ] eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" if [ -w /home/linuxbrew/.linuxbrew ] - if [ ! -L (brew --prefix)/share/fish/vendor_completions.d/brew ] - brew completions link > /dev/null - end + if [ ! -L (brew --prefix)/share/fish/vendor_completions.d/brew ] + brew completions link > /dev/null + end end if test -d (brew --prefix)/share/fish/completions - set -p fish_complete_path (brew --prefix)/share/fish/completions + set -p fish_complete_path (brew --prefix)/share/fish/completions end if test -d (brew --prefix)/share/fish/vendor_completions.d - set -p fish_complete_path (brew --prefix)/share/fish/vendor_completions.d + set -p fish_complete_path (brew --prefix)/share/fish/vendor_completions.d end + end end + set __brew_instance_initialize 1 + brew $argv + end end + +alias brew=brew_new_instance + +