|
6 | 6 | }: |
7 | 7 | { |
8 | 8 | programs = { |
| 9 | + fzf = { |
| 10 | + enable = true; |
| 11 | + enableZshIntegration = true; |
| 12 | + }; |
| 13 | + |
9 | 14 | starship = { |
10 | 15 | enable = true; |
11 | 16 | enableZshIntegration = true; |
|
44 | 49 | syntaxHighlighting = { |
45 | 50 | enable = true; |
46 | 51 | }; |
47 | | - initExtraFirst = # bash |
| 52 | + # initExtraFirst = # bash |
| 53 | + # '' |
| 54 | + # # avoid duplicated entries in PATH |
| 55 | + # typeset -U PATH |
| 56 | + # |
| 57 | + # # try to correct the spelling of commands |
| 58 | + # setopt correct |
| 59 | + # # disable C-S/C-Q |
| 60 | + # setopt noflowcontrol |
| 61 | + # # disable "no matches found" check |
| 62 | + # unsetopt nomatch |
| 63 | + # |
| 64 | + # # autosuggests otherwise breaks these widgets. |
| 65 | + # # <https://github.com/zsh-users/zsh-autosuggestions/issues/619> |
| 66 | + # ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(history-beginning-search-backward-end history-beginning-search-forward-end) |
| 67 | + # |
| 68 | + # # Do this early so fast-syntax-highlighting can wrap and override this |
| 69 | + # if autoload history-search-end; then |
| 70 | + # zle -N history-beginning-search-backward-end history-search-end |
| 71 | + # zle -N history-beginning-search-forward-end history-search-end |
| 72 | + # fi |
| 73 | + # |
| 74 | + # source <(${lib.getExe config.programs.fzf.package} --zsh) |
| 75 | + # source ${config.programs.git.package}/share/git/contrib/completion/git-prompt.sh |
| 76 | + # |
| 77 | + # # Prevent the command from being written to history before it's |
| 78 | + # # executed; save it to LASTHIST instead. Write it to history |
| 79 | + # # in precmd. |
| 80 | + # # |
| 81 | + # # called before a history line is saved. See zshmisc(1). |
| 82 | + # function zshaddhistory() { |
| 83 | + # # Remove line continuations since otherwise a "\" will eventually |
| 84 | + # # get written to history with no newline. |
| 85 | + # LASTHIST=''${1//\\$'\n'/} |
| 86 | + # # Return value 2: "... the history line will be saved on the internal |
| 87 | + # # history list, but not written to the history file". |
| 88 | + # return 2 |
| 89 | + # } |
| 90 | + # |
| 91 | + # # zsh hook called before the prompt is printed. See zshmisc(1). |
| 92 | + # function precmd() { |
| 93 | + # # Write the last command if successful, using the history buffered by |
| 94 | + # # zshaddhistory(). |
| 95 | + # if [[ $? == 0 && -n ''${LASTHIST//[[:space:]\n]/} && -n $HISTFILE ]] ; then |
| 96 | + # print -sr -- ''${=''${LASTHIST%%'\n'}} |
| 97 | + # fi |
| 98 | + # } |
| 99 | + # ''; |
| 100 | + initExtra = # sh |
48 | 101 | '' |
49 | | - # avoid duplicated entries in PATH |
50 | | - typeset -U PATH |
| 102 | + setopt inc_append_history |
51 | 103 |
|
52 | | - # try to correct the spelling of commands |
53 | | - setopt correct |
54 | | - # disable C-S/C-Q |
55 | | - setopt noflowcontrol |
56 | | - # disable "no matches found" check |
57 | | - unsetopt nomatch |
| 104 | + source "${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh" |
| 105 | + source "${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh" |
| 106 | + source "${pkgs.fzf}/share/fzf/key-bindings.zsh" |
58 | 107 |
|
59 | | - # autosuggests otherwise breaks these widgets. |
60 | | - # <https://github.com/zsh-users/zsh-autosuggestions/issues/619> |
61 | | - ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(history-beginning-search-backward-end history-beginning-search-forward-end) |
| 108 | + _zsh_cli_fg() { fg; } |
| 109 | + zle -N _zsh_cli_fg |
| 110 | + bindkey '^Z' _zsh_cli_fg |
62 | 111 |
|
63 | | - # Do this early so fast-syntax-highlighting can wrap and override this |
64 | | - if autoload history-search-end; then |
65 | | - zle -N history-beginning-search-backward-end history-search-end |
66 | | - zle -N history-beginning-search-forward-end history-search-end |
67 | | - fi |
68 | | -
|
69 | | - source <(${lib.getExe config.programs.fzf.package} --zsh) |
70 | | - source ${config.programs.git.package}/share/git/contrib/completion/git-prompt.sh |
71 | | -
|
72 | | - # Prevent the command from being written to history before it's |
73 | | - # executed; save it to LASTHIST instead. Write it to history |
74 | | - # in precmd. |
75 | | - # |
76 | | - # called before a history line is saved. See zshmisc(1). |
77 | | - function zshaddhistory() { |
78 | | - # Remove line continuations since otherwise a "\" will eventually |
79 | | - # get written to history with no newline. |
80 | | - LASTHIST=''${1//\\$'\n'/} |
81 | | - # Return value 2: "... the history line will be saved on the internal |
82 | | - # history list, but not written to the history file". |
83 | | - return 2 |
| 112 | + function set_win_title(){ |
| 113 | + echo -ne "\033]0; $(basename "$PWD") \007" |
84 | 114 | } |
85 | 115 |
|
86 | | - # zsh hook called before the prompt is printed. See zshmisc(1). |
87 | | - function precmd() { |
88 | | - # Write the last command if successful, using the history buffered by |
89 | | - # zshaddhistory(). |
90 | | - if [[ $? == 0 && -n ''${LASTHIST//[[:space:]\n]/} && -n $HISTFILE ]] ; then |
91 | | - print -sr -- ''${=''${LASTHIST%%'\n'}} |
92 | | - fi |
93 | | - } |
| 116 | + precmd_functions+=(set_win_title) |
| 117 | +
|
| 118 | + source "${pkgs.kubectl}/share/zsh/site-functions/_kubectl" |
94 | 119 | ''; |
95 | | - plugins = [ |
96 | | - { |
97 | | - # Must be before plugins that wrap widgets, such as zsh-autosuggestions or fast-syntax-highlighting |
98 | | - name = "fzf-tab"; |
99 | | - file = "share/fzf-tab/fzf-tab.plugin.zsh"; |
100 | | - src = pkgs.zsh-fzf-tab; |
101 | | - } |
102 | | - { |
103 | | - name = "zsh-nix-shell"; |
104 | | - file = "share/zsh-nix-shell/nix-shell.plugin.zsh"; |
105 | | - src = pkgs.zsh-nix-shell; |
106 | | - } |
107 | | - { |
108 | | - name = "zsh-vi-mode"; |
109 | | - src = pkgs.zsh-vi-mode; |
110 | | - file = "share/zsh-vi-mode/zsh-vi-mode.plugin.zsh"; |
111 | | - } |
112 | | - { |
113 | | - name = "fast-syntax-highlighting"; |
114 | | - file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh"; |
115 | | - src = pkgs.zsh-fast-syntax-highlighting; |
116 | | - } |
117 | | - { |
118 | | - name = "zsh-autosuggestions"; |
119 | | - file = "share/zsh-autosuggestions/zsh-autosuggestions.zsh"; |
120 | | - src = pkgs.zsh-autosuggestions; |
121 | | - } |
122 | | - { |
123 | | - name = "zsh-better-npm-completion"; |
124 | | - src = pkgs.zsh-better-npm-completion; |
125 | | - } |
126 | | - { |
127 | | - name = "zsh-command-time"; |
128 | | - src = pkgs.zsh-command-time; |
129 | | - } |
130 | | - { |
131 | | - name = "zsh-history-to-fish"; |
132 | | - src = pkgs.zsh-history-to-fish; |
133 | | - } |
134 | | - { |
135 | | - name = "zsh-you-should-use"; |
136 | | - src = pkgs.zsh-you-should-use; |
137 | | - } |
138 | | - ]; |
| 120 | + # plugins = [ |
| 121 | + # { |
| 122 | + # # Must be before plugins that wrap widgets, such as zsh-autosuggestions or fast-syntax-highlighting |
| 123 | + # name = "fzf-tab"; |
| 124 | + # file = "share/fzf-tab/fzf-tab.plugin.zsh"; |
| 125 | + # src = pkgs.zsh-fzf-tab; |
| 126 | + # } |
| 127 | + # { |
| 128 | + # name = "zsh-nix-shell"; |
| 129 | + # file = "share/zsh-nix-shell/nix-shell.plugin.zsh"; |
| 130 | + # src = pkgs.zsh-nix-shell; |
| 131 | + # } |
| 132 | + # { |
| 133 | + # name = "zsh-vi-mode"; |
| 134 | + # src = pkgs.zsh-vi-mode; |
| 135 | + # file = "share/zsh-vi-mode/zsh-vi-mode.plugin.zsh"; |
| 136 | + # } |
| 137 | + # { |
| 138 | + # name = "fast-syntax-highlighting"; |
| 139 | + # file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh"; |
| 140 | + # src = pkgs.zsh-fast-syntax-highlighting; |
| 141 | + # } |
| 142 | + # { |
| 143 | + # name = "zsh-autosuggestions"; |
| 144 | + # file = "share/zsh-autosuggestions/zsh-autosuggestions.zsh"; |
| 145 | + # src = pkgs.zsh-autosuggestions; |
| 146 | + # } |
| 147 | + # { |
| 148 | + # name = "zsh-better-npm-completion"; |
| 149 | + # src = pkgs.zsh-better-npm-completion; |
| 150 | + # } |
| 151 | + # { |
| 152 | + # name = "zsh-command-time"; |
| 153 | + # src = pkgs.zsh-command-time; |
| 154 | + # } |
| 155 | + # { |
| 156 | + # name = "zsh-history-to-fish"; |
| 157 | + # src = pkgs.zsh-history-to-fish; |
| 158 | + # } |
| 159 | + # { |
| 160 | + # name = "zsh-you-should-use"; |
| 161 | + # src = pkgs.zsh-you-should-use; |
| 162 | + # } |
| 163 | + # ]; |
139 | 164 | }; |
140 | 165 | }; |
141 | 166 | } |
0 commit comments