From 80d23ee06cff0d0bef20b9327566f7de2498f4cb Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 6 Oct 2021 00:20:32 +0200 Subject: [PATCH] fzf: do shell initialization a bit earlier This is to better integrate with more advanced shell history managers like McFly and Atuin. By initializing fzf first, we allow the history managers to steal the C-r key binding from fzf. --- modules/programs/fzf.nix | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/programs/fzf.nix b/modules/programs/fzf.nix index 6cdd894d2..145781d83 100644 --- a/modules/programs/fzf.nix +++ b/modules/programs/fzf.nix @@ -146,19 +146,25 @@ in { FZF_TMUX_OPTS = cfg.tmux.shellIntegrationOptions; }); - programs.bash.initExtra = mkIf cfg.enableBashIntegration '' + # Note, since fzf unconditionally binds C-r we use `mkOrder` to make the + # initialization show up a bit earlier. This is to make initialization of + # other history managers, like mcfly or atuin, take precedence. + programs.bash.initExtra = mkIf cfg.enableBashIntegration (mkOrder 200 '' if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then . ${cfg.package}/share/fzf/completion.bash . ${cfg.package}/share/fzf/key-bindings.bash fi - ''; + ''); - programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' + # Note, since fzf unconditionally binds C-r we use `mkOrder` to make the + # initialization show up a bit earlier. This is to make initialization of + # other history managers, like mcfly or atuin, take precedence. + programs.zsh.initExtra = mkIf cfg.enableZshIntegration (mkOrder 200 '' if [[ $options[zle] = on ]]; then . ${cfg.package}/share/fzf/completion.zsh . ${cfg.package}/share/fzf/key-bindings.zsh fi - ''; + ''); programs.fish.shellInit = mkIf cfg.enableFishIntegration '' source ${cfg.package}/share/fzf/key-bindings.fish && fzf_key_bindings