From 9daa1838d3d06fda9a5aee03738e677d7a5837ba Mon Sep 17 00:00:00 2001 From: Bouke van der Bijl Date: Wed, 17 Jun 2020 18:59:35 +0200 Subject: [PATCH 1/2] fish: replace use of tr with string split This shaves about 4ms off fish start time. Before (profiled with 'fish --profile prof.txt -c fish_prompt'): 225 4636 ----> set -l __nix_profile_paths (echo $NIX_PROFILES | /nix/store/m5ajgnzp2512na31brwfmydwk3l1gawb-coreutils-8.31/bin/tr ' ' '\n')[-1..1] 4411 4411 -----> echo $NIX_PROFILES | /nix/store/m5ajgnzp2512na31brwfmydwk3l1gawb-coreutils-8.31/bin/tr ' ' '\n' After: 190 248 ----> set -l __nix_profile_paths (string split ' ' $NIX_PROFILES)[-1..1] --- pkgs/shells/fish/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/shells/fish/default.nix b/pkgs/shells/fish/default.nix index 11d9e48008f..57c52a411d3 100644 --- a/pkgs/shells/fish/default.nix +++ b/pkgs/shells/fish/default.nix @@ -79,7 +79,7 @@ let # additional profiles are expected in order of precedence, which means the reverse of the # NIX_PROFILES variable (same as config.environment.profiles) - set -l __nix_profile_paths (echo $NIX_PROFILES | ${coreutils}/bin/tr ' ' '\n')[-1..1] + set -l __nix_profile_paths (string split ' ' $NIX_PROFILES)[-1..1] set __extra_completionsdir \ $__nix_profile_paths"/etc/fish/completions" \ From 84e25cf478d8f81070659a30f5181b0e11a028ff Mon Sep 17 00:00:00 2001 From: Bouke van der Bijl Date: Wed, 17 Jun 2020 18:59:56 +0200 Subject: [PATCH 2/2] fish: use -p to prepend profile directories --- pkgs/shells/fish/default.nix | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pkgs/shells/fish/default.nix b/pkgs/shells/fish/default.nix index 57c52a411d3..a6ce7bf6d23 100644 --- a/pkgs/shells/fish/default.nix +++ b/pkgs/shells/fish/default.nix @@ -81,18 +81,15 @@ let # NIX_PROFILES variable (same as config.environment.profiles) set -l __nix_profile_paths (string split ' ' $NIX_PROFILES)[-1..1] - set __extra_completionsdir \ + set -p __extra_completionsdir \ $__nix_profile_paths"/etc/fish/completions" \ - $__nix_profile_paths"/share/fish/vendor_completions.d" \ - $__extra_completionsdir - set __extra_functionsdir \ + $__nix_profile_paths"/share/fish/vendor_completions.d" + set -p __extra_functionsdir \ $__nix_profile_paths"/etc/fish/functions" \ - $__nix_profile_paths"/share/fish/vendor_functions.d" \ - $__extra_functionsdir - set __extra_confdir \ + $__nix_profile_paths"/share/fish/vendor_functions.d" + set -p __extra_confdir \ $__nix_profile_paths"/etc/fish/conf.d" \ - $__nix_profile_paths"/share/fish/vendor_conf.d" \ - $__extra_confdir + $__nix_profile_paths"/share/fish/vendor_conf.d" end '';