aboutsummaryrefslogtreecommitdiff
path: root/common/.flake/home/programs/zsh.nix.org
blob: 79795d09919c05731c9b1270d32ced7a0a19df62 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#+title: ZSH Configuration

Open =zsh= configuration.
#+begin_src nix :tangle ~/.flake/home/programs/zsh.nix :mkdirp yes
  { config, pkgs, ... }:

  {
    programs.zsh = {
      enable = true;
#+end_src

Automatically =cd= if only the path is used.
#+begin_src nix :tangle ~/.flake/home/programs/zsh.nix :mkdirp yes
      autocd = true;
#+end_src

Enable auto-suggestions.
#+begin_src nix :tangle ~/.flake/home/programs/zsh.nix :mkdirp yes
      autosuggestion = {
        enable = true;
      };
#+end_src

Use =vi= keybindings.
#+begin_src nix :tangle ~/.flake/home/programs/zsh.nix :mkdirp yes
      defaultKeymap = "viins";
#+end_src

Append to the history and ignore duplicates.
#+begin_src nix :tangle ~/.flake/home/programs/zsh.nix :mkdirp yes
      history = {
        append = true;
        ignoreAllDups = true;
      };
#+end_src

Specify =ls= aliases.
#+begin_src nix :tangle ~/.flake/home/programs/zsh.nix :mkdirp yes
      shellAliases = {
        "ll" = "ls -alF";
        "la" = "ls -a";
        "l" = "ls -F";
        "sl" = "ls";
      };
#+end_src

Enable syntax highlighting.
#+begin_src nix :tangle ~/.flake/home/programs/zsh.nix :mkdirp yes
      syntaxHighlighting.enable = true;
#+end_src

Create potential aliases and create the prompt.
#+begin_src nix :tangle ~/.flake/home/programs/zsh.nix :mkdirp yes
      initExtra = ''
      which lesspipe.sh &> /dev/null && export LESSOPEN="|lesspipe.sh %s"
      which eza &> /dev/null && alias ls=eza
      parse_git_dirty() {
        git_status="$(git status 2> /dev/null)"
        [[ "$git_status" =~ "use \"git push\" to publish your local commits" ]] && echo -n " %F{green}%f"
        [[ "$git_status" =~ "Changes to be committed:" ]] && echo -n " %F{magenta}%f"
        [[ "$git_status" =~ "Changes not staged for commit:" ]] && echo -n " %F{yellow}%f"
        [[ "$git_status" =~ "Untracked files:" ]] && echo -n " %F{red}%f"
      }
      setopt prompt_subst
      autoload -Uz vcs_info
      precmd () { vcs_info }
      zstyle ':vcs_info:*' formats ' %F{blue}%b%f' # git(main)
      PS1='%(?..%B%F{red}[%?%\]%f%b )%F{green}%20<...<%~%<<%f$vcs_info_msg_0_$(parse_git_dirty) $ '
      '';
#+end_src

Launch =ssh-agent= at login.
#+begin_src nix :tangle ~/.flake/home/programs/zsh.nix :mkdirp yes
      profileExtra = ''
      if [ ! -S ~/.ssh/ssh_auth_sock ]; then
          eval `ssh-agent` > /dev/null
          ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
      fi
      export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
      '';
#+end_src

Close =zsh= configuration.
#+begin_src nix :tangle ~/.flake/home/programs/zsh.nix :mkdirp yes
    };
  }
#+end_src