aboutsummaryrefslogtreecommitdiffstats
path: root/modules/programs/zsh/default.nix
blob: 482c201fadc8e04608ff6c5efa138a6a3b6638b8 (plain)
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
{
  config,
  lib,
  pkgs,
  ...
}:

# Zsh - Z shell, extended bash with additional features and plugins
{
  config =
    let
      nixCommandWrappers = builtins.readFile ./nix-aliases.sh;
    in
    lib.mkIf config.programs.zsh.enable {
      programs.zsh = {
        package = pkgs.zsh;
        dotDir = "${config.xdg.configHome}/zsh";
        history.path = "${config.xdg.cacheHome}/zsh/history";
        enableCompletion = true;
        initContent = ''
          setopt PROMPT_SUBST

          autoload -U colors && colors

          bindkey "^[[3~" delete-char
          bindkey "^?" backward-delete-char
          ${nixCommandWrappers}
        '';
      };

      programs.bash.initExtra = lib.mkIf config.programs.bash.enable (lib.mkAfter nixCommandWrappers);

      home.sessionVariables.SHELL = "${lib.getExe config.programs.zsh.package}";
    };
}