diff --git a/home/isabel/fish.nix b/home/isabel/fish.nix index 7c5ec33f..9296e644 100644 --- a/home/isabel/fish.nix +++ b/home/isabel/fish.nix @@ -27,6 +27,8 @@ in }; }; + home.shell.enableFishIntegration = false; + programs.fish = { plugins = [ ]; @@ -35,11 +37,12 @@ in df = "df -h"; # human readblity rs = "systemctl reboot"; jctl = "journalctl -p 3 -xb"; # get error messages from journalctl - lg = "lazygit"; + # lg = "lazygit"; }; functions = { bj = "nohup $argv /dev/null &"; + "." = '' set -l input $argv[1] if echo $input | grep -q '^[1-9][0-9]*$' @@ -51,6 +54,15 @@ in echo "Invalid input format. Please use '' to go back a specific number of directories." end ''; + + lg = '' + set -x LAZYGIT_NEW_DIR_FILE /home/isabel/.cache/lazygit/newdir + command lazygit $argv + if test -f $LAZYGIT_NEW_DIR_FILE + cd (cat $LAZYGIT_NEW_DIR_FILE) + rm -f $LAZYGIT_NEW_DIR_FILE + end + ''; }; loginShellInit = optionalString pkgs.stdenv.hostPlatform.isDarwin '' @@ -65,4 +77,60 @@ in set -g theme_newline_cursor yes ''; }; + + # generate each tool's shell integration at build time and drop it into a + # conf.d file, rather than running the tool on every interactive shell startup. + # each mkCmd just emits its integration to stdout; the wrapper guards it behind + # `status is-interactive` so it only loads in interactive shells, matching where + # these used to live in config.fish. + xdg.configFile = + lib.mapAttrs' + ( + name: mkCmd: + lib.nameValuePair "fish/conf.d/${name}.fish" { + source = + pkgs.runCommand "${name}-fish-config.fish" + { + nativeBuildInputs = [ pkgs.writableTmpDirAsHomeHook ]; + } + '' + { + echo 'status is-interactive; and begin' + ${mkCmd config.programs.${name}} + echo # ensure the closing `end` lands on its own line + echo end + } > "$out" + ''; + } + ) + { + atuin = cfg: '' + ${lib.getExe cfg.package} init fish ${lib.escapeShellArgs cfg.flags} + ''; + + fzf = cfg: '' + ${lib.getExe cfg.package} --fish + ''; + + zoxide = cfg: '' + ${lib.getExe cfg.package} init fish ${lib.concatStringsSep " " cfg.options} + ''; + + starship = cfg: '' + echo 'if test "$TERM" != "dumb"' + ${lib.getExe cfg.package} init fish + echo # starship's init emits no trailing newline, so terminate it + echo end + ''; + + nix-your-shell = cfg: '' + ${lib.getExe cfg.package} fish + ''; + + direnv = cfg: '' + echo 'if not functions -q __direnv_export_eval' + ${lib.getExe cfg.package} hook fish + echo end + ''; + }; } diff --git a/modules/home/environment/default.nix b/modules/home/environment/default.nix index 4ca86528..1487fe62 100644 --- a/modules/home/environment/default.nix +++ b/modules/home/environment/default.nix @@ -2,7 +2,6 @@ imports = [ # keep-sorted start ./path.nix # set our path - ./shell.nix # enable our shell intergrations ./variables.nix # set our environment variables ./xdg.nix # set xdg expectations # keep-sorted end diff --git a/modules/home/environment/shell.nix b/modules/home/environment/shell.nix deleted file mode 100644 index 8fed15cf..00000000 --- a/modules/home/environment/shell.nix +++ /dev/null @@ -1,14 +0,0 @@ -# this file is used to enable or disable shell intergrations based on the shell itself -{ config, ... }: -{ - home.shell = { - # disable the global enable - enableShellIntegration = false; - - enableBashIntegration = config.programs.bash.enable; - enableIonIntegration = config.programs.ion.enable; - enableNushellIntegration = config.programs.nushell.enable; - enableZshIntegration = config.programs.zsh.enable; - enableFishIntegration = config.programs.fish.enable; - }; -}