|
25 | 25 | programs.zsh = {
|
26 | 26 | enable = true;
|
27 | 27 | package = pkgsUnstable.zsh;
|
28 |
| - |
29 |
| - # TODO wait for https://github.com/nix-community/home-manager/pull/7333 |
30 |
| - initContent = '' |
31 |
| - setopt INC_APPEND_HISTORY |
32 |
| - ''; |
| 28 | + # Preferred over the explicit NixOS options: |
| 29 | + # https://github.com/nix-community/home-manager/pull/7333#issuecomment-3225914278 |
| 30 | + # |
| 31 | + # Context: |
| 32 | + # - https://www.soberkoder.com/better-zsh-history/ |
| 33 | + # - https://zsh.sourceforge.io/Doc/Release/Options.html |
| 34 | + # - https://zsh.sourceforge.io/Doc/Release/Parameters.html |
| 35 | + setOptions = |
| 36 | + lib.mapAttrsToList (name: enabled: if enabled then name else "NO_${name}") { |
| 37 | + APPEND_HISTORY = false; |
| 38 | + EXTENDED_HISTORY = true; |
| 39 | + HIST_EXPIRE_DUPS_FIRST = false; |
| 40 | + HIST_FCNTL_LOCK = true; |
| 41 | + HIST_FIND_NO_DUPS = false; |
| 42 | + HIST_IGNORE_ALL_DUPS = false; |
| 43 | + HIST_IGNORE_DUPS = true; |
| 44 | + HIST_IGNORE_SPACE = true; |
| 45 | + HIST_SAVE_NO_DUPS = false; |
| 46 | + INC_APPEND_HISTORY = true; |
| 47 | + # I prefer "INC_APPEND_HISTORY" over this, as I frequently work |
| 48 | + # with multiple terminals simultaneously that should keep their own |
| 49 | + # history as long as they are running. |
| 50 | + SHARE_HISTORY = false; |
| 51 | + }; |
33 | 52 |
|
34 | 53 | # Context:
|
35 | 54 | # - https://www.soberkoder.com/better-zsh-history/
|
|
44 | 63 | saveLines = 200000; # This results in roughly 1-6 MiB memory usage.
|
45 | 64 | in
|
46 | 65 | {
|
47 |
| - # INC_APPEND_HISTORY |
48 |
| - # Append new commands immediately to the hist file. |
49 |
| - # TODO wait for https://github.com/nix-community/home-manager/pull/7333 |
50 |
| - # appendInc = true; |
51 |
| - # EXTENDED_HISTORY |
52 |
| - # Save timestamp into the history file. |
53 |
| - extended = true; |
54 |
| - # HIST_IGNORE_DUPS |
55 |
| - # Don't push commands to the history if they are a duplicate of the |
56 |
| - # previous command. |
57 |
| - ignoreDups = true; |
58 |
| - # HIST_IGNORE_ALL_DUPS |
59 |
| - # Don't remove old duplicates (not previous command) from history. |
60 |
| - ignoreAllDups = false; |
61 |
| - # HIST_IGNORE_SPACE |
62 |
| - # Do not enter command lines into the history list if the first |
63 |
| - # character is a space. |
64 |
| - ignoreSpace = true; |
| 66 | + |
65 | 67 | # SAVEHIST
|
66 | 68 | # Number of history lines to save on disk.
|
67 | 69 | save = saveLines;
|
68 | 70 | # HISTSIZE
|
69 | 71 | # Number of history lines to load into memory.
|
70 | 72 | size = saveLines;
|
71 |
| - # SHARE_HISTORY |
72 |
| - # I'm using the mutually exclusive alternative INC_APPEND_HISTORY. |
73 |
| - share = false; |
74 | 73 | };
|
75 | 74 |
|
76 | 75 | oh-my-zsh = {
|
|
0 commit comments