|
64 | 64 | '';
|
65 | 65 | };
|
66 | 66 |
|
| 67 | + appendInc = mkOption { |
| 68 | + type = types.bool; |
| 69 | + default = false; |
| 70 | + description = '' |
| 71 | + This option works like `programs.zsh.history.append` except that |
| 72 | + new history lines are added to the $HISTFILE incrementally (as |
| 73 | + soon as they are entered), rather than waiting until the shell |
| 74 | + exits. The file will still be periodically re-written to trim it |
| 75 | + when the number of lines grows 20% beyond the value specified by |
| 76 | + `programs.zsh.history.save`. |
| 77 | + ''; |
| 78 | + }; |
| 79 | + |
| 80 | + appendIncTime = mkOption { |
| 81 | + type = types.bool; |
| 82 | + default = false; |
| 83 | + description = '' |
| 84 | + This option is a variant of `programs.zsh.history.appendInc` in |
| 85 | + which, where possible, the history entry is written out to the |
| 86 | + file after the command is finished, so that the time taken by |
| 87 | + the command is recorded correctly in the history file in |
| 88 | + EXTENDED_HISTORY format. This means that the history entry will |
| 89 | + not be available immediately from other instances of the shell |
| 90 | + that are using the same history file. |
| 91 | +
|
| 92 | + This option is only useful if `programs.zsh.history.append` and |
| 93 | + `programs.zsh.history.share` are turned off. The three options |
| 94 | + should be considered mutually exclusive. |
| 95 | + ''; |
| 96 | + }; |
| 97 | + |
67 | 98 | size = mkOption {
|
68 | 99 | type = types.int;
|
69 | 100 | default = 10000;
|
|
162 | 193 | share = mkOption {
|
163 | 194 | type = types.bool;
|
164 | 195 | default = true;
|
165 |
| - description = "Share command history between zsh sessions."; |
| 196 | + description = '' |
| 197 | + This option both imports new commands from the history file, |
| 198 | + and also causes your typed commands to be appended to the |
| 199 | + history file (the latter is like specifying |
| 200 | + `programs.zsh.history.append`, which should be turned off |
| 201 | + if this option is in effect). The history lines are also output |
| 202 | + with timestamps ala `programs.zsh.history.extended` (which makes |
| 203 | + it easier to find the spot where we left off reading the file |
| 204 | + after it gets re-written). |
| 205 | + ''; |
166 | 206 | };
|
167 | 207 | };
|
168 | 208 | }
|
|
678 | 718 | in
|
679 | 719 | mkIf cfg.enable (
|
680 | 720 | lib.mkMerge [
|
| 721 | + { |
| 722 | + assertions = with config.programs.zsh; [ |
| 723 | + { |
| 724 | + assertion = history.share -> !history.appendInc && !history.appendIncTime; |
| 725 | + message = "zsh.hist.share can't be mixed with zsh.hist.appendInc or zsh.hist.appendIncTime"; |
| 726 | + } |
| 727 | + { |
| 728 | + assertion = history.appendInc -> !history.appendIncTime && !history.share; |
| 729 | + message = "zsh.hist.appendInc can't be mixed with zsh.hist.appendIncTime or zsh.hist.share"; |
| 730 | + } |
| 731 | + { |
| 732 | + assertion = history.appendIncTime -> !history.appendInc && !history.share; |
| 733 | + message = "zsh.hist.appendIncTime can't be mixed with zsh.hist.appendInc or zsh.hist.share"; |
| 734 | + } |
| 735 | + ]; |
| 736 | + } |
| 737 | + |
681 | 738 | (mkIf (cfg.envExtra != "") {
|
682 | 739 | home.file."${relToDotDir ".zshenv"}".text = cfg.envExtra;
|
683 | 740 | })
|
|
854 | 911 |
|
855 | 912 | setopt HIST_FCNTL_LOCK
|
856 | 913 | ${if cfg.history.append then "setopt" else "unsetopt"} APPEND_HISTORY
|
| 914 | + ${if cfg.history.appendInc then "setopt" else "unsetopt"} INC_APPEND_HISTORY |
| 915 | + ${if cfg.history.appendIncTime then "setopt" else "unsetopt"} INC_APPEND_HISTORY_TIME |
857 | 916 | ${if cfg.history.expireDuplicatesFirst then "setopt" else "unsetopt"} HIST_EXPIRE_DUPS_FIRST
|
858 | 917 | ${if cfg.history.extended then "setopt" else "unsetopt"} EXTENDED_HISTORY
|
859 | 918 | ${if cfg.history.findNoDups then "setopt" else "unsetopt"} HIST_FIND_NO_DUPS
|
|
0 commit comments