aboutsummaryrefslogtreecommitdiff
path: root/home/shell/fish/default.nix
blob: c81f18859ee0bdfd316b1cd50d2c29f79d11a5f8 (plain) (blame)
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
{ config, lib, pkgs, ... }:
let
  cfg = config.my.home.shell;
  swayEnabled = config.my.home.wm.windowManager == "sway";
  aliases = config.my.home.shell.aliases;
in
{
  config = lib.mkIf (cfg.name == "fish") {
    programs.fish = {
      enable = true;
      shellAliases = aliases;
      interactiveShellInit = ''
        set fish_greeting

        # Tmux on terminal start, unless we're in a SSH connection
        if status is-interactive
          if test -z "$SSH_CONNECTION"
            if not tmux has-session 2>/dev/null; or test -z "$TMUX"
              exec tmux new-session -A -s 0
            end
          end
        end
      '';
      loginShellInit = lib.mkIf swayEnabled ''
        if test -z "$DISPLAY"; and test (tty) = "/dev/tty1"
          exec sway
        end
      '';
    };
  };
}