Skip to content

Commit c33372d

Browse files
committed
common(modules,user-env): restructure zsh options
Seems to be the new preferable way [0]. [0] nix-community/home-manager#7333 (comment)
1 parent fc3778b commit c33372d

File tree

1 file changed

+25
-26
lines changed
  • common/modules/user-env/programs/cli

1 file changed

+25
-26
lines changed

common/modules/user-env/programs/cli/zsh.nix

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,30 @@ in
2525
programs.zsh = {
2626
enable = true;
2727
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+
};
3352

3453
# Context:
3554
# - https://www.soberkoder.com/better-zsh-history/
@@ -44,33 +63,13 @@ in
4463
saveLines = 200000; # This results in roughly 1-6 MiB memory usage.
4564
in
4665
{
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+
6567
# SAVEHIST
6668
# Number of history lines to save on disk.
6769
save = saveLines;
6870
# HISTSIZE
6971
# Number of history lines to load into memory.
7072
size = saveLines;
71-
# SHARE_HISTORY
72-
# I'm using the mutually exclusive alternative INC_APPEND_HISTORY.
73-
share = false;
7473
};
7574

7675
oh-my-zsh = {

0 commit comments

Comments
 (0)