summaryrefslogtreecommitdiffstats
path: root/common/commandline/zsh.nix
blob: 33763217b2099f224b3006d05c53988945fb92ed (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
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, lib, pkgs, ... }:

with import ../../lib/theme.nix { inherit lib; };
let
  dominantEscapeCode = fgEscapeCode config.theme.colors.dominant;
in
{
  programs.zsh = {
    enable = true;

    interactiveShellInit = with lib;
    ''
      source "${pkgs.grml-zsh-config}/etc/zsh/zshrc"
      is4 && xsource "${pkgs.grml-zsh-config}/etc/zsh/keephack"

      PATH="${pkgs.pazi}/bin:$PATH"
      eval "$(pazi init zsh)"

      source "${pkgs.zsh-history-substring-search}/share/zsh-history-substring-search/zsh-history-substring-search.zsh"

      function () {
        local dominant_escape_code="${dominantEscapeCode}"
        local dim_fg_escape_code="${fgEscapeCode config.theme.colors.dimForeground}"

        ${builtins.readFile ../../dotfiles/zshrc}
      }

      # Grml's ZSH config overrides less variables
      export ${concatStringsSep " "
        (mapAttrsToList
          (variable: value: "${variable}=\"${value}\"")
          config.programs.less.envVariables)}

      #eval "$(${pkgs.starship}/bin/starship init zsh)"
    '';

    # otherwise it'll override the grml prompt
    promptInit = "";
    # Grml handles that, and supports cache (faster!!!)
    enableGlobalCompInit = false;

    syntaxHighlighting = {
      enable = true;
      highlighters = [ "main" "brackets" "line" ];
    };

    shellAliases = {
      e = "\${(z)EDITOR}";
    };

    setOptions = [
      "HIST_IGNORE_DUPS" "SHARE_HISTORY" "HIST_FCNTL_LOCK"
      "NO_CLOBBER"
      "NO_CASE_GLOB"
    ];
  };

  users.defaultUserShell = pkgs.zsh;
}