about summary refs log tree commit diff
path: root/users/fcuny/cli/zsh.nix
blob: a27a3c1113a4101b8b5e9d6ac17ff610cbb3db55 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{config, lib, pkgs, ...}:

{

  programs.zsh = {
    enable = true;
    enableAutosuggestions = true;
    enableCompletion = true;
    defaultKeymap = "emacs";
    history = {
      save = 100000;
      extended = true;
      ignoreDups = true;
    };

    initExtraFirst = ''
      # Activate home-manager environment, if not already enabled
      [ -d "$HOME/.nix-profile" ] || /nix/var/nix/profiles/per-user/$USER/home-manager/activate &> /dev/null
    '';

    initExtra = ''
      # Print timing statistics for everything which takes longer than 5 seconds of
      # user + system time ('sleep 6' does not work because of 0% user/system time!).
      REPORTTIME=5

      autoload -U colors && colors

      autoload -Uz vcs_info add-zsh-hook
      setopt prompt_subst

      add-zsh-hook precmd vcs_info

      # Enable checking for (un)staged changes, enabling use of %u and %c
      zstyle ':vcs_info:*' check-for-changes true

      PROMPT='%K{cyan}%F{black}%m%k%f %~%F{red}$vcs_info_msg_0_%f %# '

      # man zshall /forward-word /backward-word - word splitting as with bash
      WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'

      # For tramp (emacs).
      if [ "$TERM" = "dumb" ]; then
        unset PROMPT
        PS1='$ '
        unsetopt zle
      fi
    '';
  };
}