all repos — nixfiles @ df256a19f1fb20294c9dac7bf3d08cc8a930402f

System and user configuration, managed by nix and home-manager

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
{
  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";
      })
    ];
    promptInit = ''
      if ! functions --query tide
        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
    '';
  };
}