From 160875183fe1acf030c8429027973885e8f41b04 Mon Sep 17 00:00:00 2001 From: Michael Cooper Date: Thu, 20 Mar 2025 08:01:30 -0700 Subject: [PATCH] mcfly: fix mcfly-fzf in non-interactive shells mcfly-fzf's initialization steps don't properly check for interactive shells. It does check, but only after checking if mcfly has been initialized. Because mcfly does not initiate itself on non-interactive shells, that causes mcfly-fzf to return an exit code, breaking non-interactive shells. --- modules/programs/mcfly.nix | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/programs/mcfly.nix b/modules/programs/mcfly.nix index cf115129d..d815a4f9f 100644 --- a/modules/programs/mcfly.nix +++ b/modules/programs/mcfly.nix @@ -7,22 +7,33 @@ let tomlFormat = pkgs.formats.toml { }; + # These shell integrations all wrap `mcfly-fzf init` in an interactive shell + # check, due to a buggy interactivity check in its initialization. + # See: https://github.com/nix-community/home-manager/issues/6663 + # and https://github.com/bnprks/mcfly-fzf/issues/10 + bashIntegration = '' eval "$(${getExe pkgs.mcfly} init bash)" '' + optionalString cfg.fzf.enable '' - eval "$(${getExe pkgs.mcfly-fzf} init bash)" + if [[ $- =~ i ]]; then + eval "$(${getExe pkgs.mcfly-fzf} init bash)" + fi ''; fishIntegration = '' ${getExe pkgs.mcfly} init fish | source '' + optionalString cfg.fzf.enable '' - ${getExe pkgs.mcfly-fzf} init fish | source + if [[ -o interactive ]]; then + ${getExe pkgs.mcfly-fzf} init fish | source + fi ''; zshIntegration = '' eval "$(${getExe pkgs.mcfly} init zsh)" '' + optionalString cfg.fzf.enable '' - eval "$(${getExe pkgs.mcfly-fzf} init zsh)" + if status is-interactive + eval "$(${getExe pkgs.mcfly-fzf} init zsh)" + end ''; in {