system/settings/programs/shell.nix (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | {
config,
pkgs,
lib,
...
}:
{
programs.fish = {
enable = true;
useBabelfish = true;
interactiveShellInit = ''
set --global fish_greeting ""
'';
shellAliases = lib.mkMerge [
{
ip6 = "ip -6";
}
(lib.mkIf pkgs.stdenv.isLinux {
ping6 = "ping -6";
jc = "journalctl";
jcu = "journalctl -u";
jcb = "journalctl -b";
jcbu = "journalctl -b -u";
sy = "systemctl";
syrs = "systemctl restart";
sys = "systemctl start";
syp = "systemctl stop";
syt = "systemctl status";
syc = "systemctl cat";
sylu = "systemctl list-units";
sylf = "systemctl list-units --failed";
syluf = "systemctl list-unit-files";
sylt = "systemctl list-timers";
})
];
promptInit = ''
if ! functions --query fish_prompt
fish_config prompt choose astronaut
end
'';
};
users = lib.optionalAttrs pkgs.stdenv.isLinux {
defaultUserShell = config.programs.fish.package;
users.root.shell = "/bin/sh";
};
programs.bash = {
interactiveShellInit = ''
# check if parent process is not fish && make nested shells work properly
if grep -qv fish /proc/$PPID/comm && [[ $SHLVL == [12] ]]; then
# set $SHELL for better integration with programs like nix shell, tmux, etc.
SHELL=${pkgs.fish}/bin/fish exec fish
fi
'';
};
}
|