nix-configs/modules/cli/fish.nix

45 lines
1.3 KiB
Nix

{
pkgs,
config,
lib,
...
}:
let
cfg = config.xyno.cli.fish;
in
{
options.xyno.cli.fish.enable = lib.mkEnableOption "enable the fish shell with xynos config";
config = lib.mkIf cfg.enable {
programs.bash = {
# auto spawn fish if interactive
interactiveShellInit = ''
if [[ ($(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING}) || -n "$IN_NIX_SHELL" ]]
then
shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION=""
exec ${pkgs.fish}/bin/fish $LOGIN_OPTION
fi
'';
};
environment.systemPackages = with pkgs; [
fishPlugins.grc
grc
fzf # needed for reverse history search
];
programs.direnv.enableFishIntegration = true;
programs.fish.generateCompletions = true;
programs.fish.interactiveShellInit = ''
set -g fish_key_bindings fish_vi_key_bindings
function fish_greeting
end
function y
set tmp (mktemp -t "yazi-cwd.XXXXXX")
yazi $argv --cwd-file="$tmp"
if set cwd (command cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ]
builtin cd -- "$cwd"
end
rm -f -- "$tmp"
end
'';
programs.fish.enable = true;
};
}