e2d157d5895717e983e5cc4e5df792a6a5dbe0ac
- Author
- Sebastian Gniazdowski <sgniazdowski@gmail.com>
- Committer
- Sebastian Gniazdowski <sgniazdowski@gmail.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/zsh-navigation-tools/.config/znt/n-aliases.conf b/plugins/zsh-navigation-tools/.config/znt/n-aliases.conf
2index 98f4625f128fdba477edc7176f7c9c3b04309d69..047b017eb7ff9daada7be7b2f28122eca10e76cf 100644
3--- a/plugins/zsh-navigation-tools/.config/znt/n-aliases.conf
4+++ b/plugins/zsh-navigation-tools/.config/znt/n-aliases.conf
5@@ -1,5 +1,33 @@
6 # How should be current element of the list drawn. Possible values: reverse,
7-# underline. Default (without option set) is reverse
8+# underline.
9 # On Linux virtual terminal this will be enforced to reverse (because of poor
10-# underline support on that terminal)
11-# local active_text=underline
12+# underline support on that terminal). The same for screen/tmux.
13+local active_text=reverse
14+
15+
16+
17+
18+
19+
20+#
21+# Zshrc integration. All below variables can
22+# be set in zshrc and will have precedence
23+# over config files
24+#
25+
26+# 1. znt_aliases_active_text
27+active_text=${znt_aliases_active_text:-$active_text}
28+
29+# 2. znt_aliases_nlist_coloring_pattern
30+NLIST_COLORING_PATTERN=${znt_aliases_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
31+
32+# 3. znt_aliases_nlist_coloring_color
33+NLIST_COLORING_COLOR=${znt_aliases_nlist_coloring_color:-$NLIST_COLORING_COLOR}
34+
35+# 4. znt_aliases_nlist_coloring_match_multiple
36+NLIST_COLORING_MATCH_MULTIPLE=${znt_aliases_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
37+
38+# 5. znt_aliases_keywords (array)
39+if (( ${+znt_aliases_keywords} )); then
40+ keywords=( "${znt_aliases_keywords[@]}" )
41+fi
42diff --git a/plugins/zsh-navigation-tools/.config/znt/n-cd.conf b/plugins/zsh-navigation-tools/.config/znt/n-cd.conf
43index 7ed7828ea4f352a13c959f2e0a25e9f6cd04fb89..8271e5d9825eb6023fbd0acc3560fe623ca196d1 100644
44--- a/plugins/zsh-navigation-tools/.config/znt/n-cd.conf
45+++ b/plugins/zsh-navigation-tools/.config/znt/n-cd.conf
46@@ -1,6 +1,6 @@
47 # Hotlist
48-# Try to use $ZSH_VERSION, e.g. /usr/share/zsh/$ZSH_VERSION/functions
49-local hotlist
50+# Can use e.g. $ZSH_VERSION, e.g. /usr/share/zsh/$ZSH_VERSION/functions
51+local -a hotlist
52 hotlist=(
53 ~/.config/znt
54 /usr/share/zsh/site-functions
55@@ -8,6 +8,7 @@ hotlist=(
56 /usr/local/share/zsh/site-functions
57 /usr/local/share/zsh
58 /usr/local/bin
59+ /usr/lib
60 )
61
62 # Suppress adding (to directory stack) directories visited by n-cd
63@@ -15,12 +16,53 @@ hotlist=(
64 local NCD_DONT_PUSHD=0
65
66 # How should be current element of the list drawn. Possible values: reverse,
67-# underline. Default (without option set) is reverse
68+# underline.
69 # On Linux virtual terminal this will be enforced to reverse (because of poor
70-# underline support on that terminal)
71-# local active_text=underline
72+# underline support on that terminal). The same for screen/tmux.
73+local active_text=reverse
74
75 # Colorize last segments of the paths
76 # (#s) is ^, (#e) is $, # is *, ## is + (comparing to regex)
77 local NLIST_COLORING_PATTERN="[a-zA-Z0-9 ._-]##/#(#e)"
78 local NLIST_COLORING_COLOR=$'\x1b[00;33m'
79+
80+# Search keywords, iterated with F2 or Ctrl-X or Ctrl-/
81+local -a keywords
82+keywords=( "zsh" "local" "git" )
83+
84+
85+
86+
87+
88+
89+
90+#
91+# Zshrc integration. All below variables can
92+# be set in zshrc and will have precedence
93+# over config files
94+#
95+
96+# 1. znt_cd_hotlist (array)
97+if (( ${+znt_cd_hotlist} )); then
98+ hotlist=( "${znt_cd_hotlist[@]}" )
99+fi
100+
101+# 2. znt_cd_dont_pushd
102+NCD_DONT_PUSHD=${znt_cd_dont_pushd:-$NCD_DONT_PUSHD}
103+
104+# 3. znt_cd_active_text
105+active_text=${znt_cd_active_text:-$active_text}
106+
107+# 4. znt_cd_nlist_coloring_pattern
108+NLIST_COLORING_PATTERN=${znt_cd_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
109+
110+# 5. znt_cd_nlist_coloring_color
111+NLIST_COLORING_COLOR=${znt_cd_nlist_coloring_color:-$NLIST_COLORING_COLOR}
112+
113+# 6. znt_cd_nlist_coloring_match_multiple
114+NLIST_COLORING_MATCH_MULTIPLE=${znt_cd_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
115+
116+# 7. znt_cd_keywords (array)
117+if (( ${+znt_cd_keywords} )); then
118+ keywords=( "${znt_cd_keywords[@]}" )
119+fi
120diff --git a/plugins/zsh-navigation-tools/.config/znt/n-env.conf b/plugins/zsh-navigation-tools/.config/znt/n-env.conf
121index 0c4bdce64938fbd29c86763acc07935c572fe933..85dda05ed4a320402c65f452ab44f3773e6bae05 100644
122--- a/plugins/zsh-navigation-tools/.config/znt/n-env.conf
123+++ b/plugins/zsh-navigation-tools/.config/znt/n-env.conf
124@@ -1,9 +1,38 @@
125 # How should be current element of the list drawn. Possible values: reverse,
126-# underline. Default (without option set) is reverse
127+# underline.
128 # On Linux virtual terminal this will be enforced to reverse (because of poor
129-# underline support on that terminal)
130-# local active_text=underline
131+# underline support on that terminal). The same for screen/tmux.
132+local active_text=reverse
133
134 # (#s) is ^, (#e) is $, # is *, ## is + (comparing to regex)
135 local NLIST_COLORING_PATTERN="[a-zA-Z0-9_]##"
136 local NLIST_COLORING_MATCH_MULTIPLE=0
137+
138+
139+
140+
141+
142+
143+
144+#
145+# Zshrc integration. All below variables can
146+# be set in zshrc and will have precedence
147+# over config files
148+#
149+
150+# 1. znt_env_active_text
151+active_text=${znt_env_active_text:-$active_text}
152+
153+# 2. znt_env_nlist_coloring_pattern
154+NLIST_COLORING_PATTERN=${znt_env_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
155+
156+# 3. znt_env_nlist_coloring_color
157+NLIST_COLORING_COLOR=${znt_env_nlist_coloring_color:-$NLIST_COLORING_COLOR}
158+
159+# 4. znt_env_nlist_coloring_match_multiple
160+NLIST_COLORING_MATCH_MULTIPLE=${znt_env_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
161+
162+# 5. znt_env_keywords (array)
163+if (( ${+znt_env_keywords} )); then
164+ keywords=( "${znt_env_keywords[@]}" )
165+fi
166diff --git a/plugins/zsh-navigation-tools/.config/znt/n-functions.conf b/plugins/zsh-navigation-tools/.config/znt/n-functions.conf
167index 93d31e8fd956dc832450c87ab195b46b94039180..d032e278894c11732a0585e8e06b0a0b9f31b31b 100644
168--- a/plugins/zsh-navigation-tools/.config/znt/n-functions.conf
169+++ b/plugins/zsh-navigation-tools/.config/znt/n-functions.conf
170@@ -4,7 +4,38 @@ local feditor="zed"
171 # local feditor="vared"
172
173 # How should be current element of the list drawn. Possible values: reverse,
174-# underline. Default (without option set) is reverse
175+# underline.
176 # On Linux virtual terminal this will be enforced to reverse (because of poor
177-# underline support on that terminal)
178-# local active_text=underline
179+# underline support on that terminal). The same for screen/tmux.
180+local active_text=reverse
181+
182+
183+
184+
185+
186+
187+#
188+# Zshrc integration. All below variables can
189+# be set in zshrc and will have precedence
190+# over config files
191+#
192+
193+# 1. znt_functions_feditor
194+feditor=${znt_functions_feditor:-$feditor}
195+
196+# 2. znt_functions_active_text
197+active_text=${znt_functions_active_text:-$active_text}
198+
199+# 3. znt_functions_nlist_coloring_pattern
200+NLIST_COLORING_PATTERN=${znt_functions_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
201+
202+# 4. znt_functions_nlist_coloring_color
203+NLIST_COLORING_COLOR=${znt_functions_nlist_coloring_color:-$NLIST_COLORING_COLOR}
204+
205+# 5. znt_functions_nlist_coloring_match_multiple
206+NLIST_COLORING_MATCH_MULTIPLE=${znt_functions_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
207+
208+# 6. znt_functions_keywords (array)
209+if (( ${+znt_functions_keywords} )); then
210+ keywords=( "${znt_functions_keywords[@]}" )
211+fi
212diff --git a/plugins/zsh-navigation-tools/.config/znt/n-history.conf b/plugins/zsh-navigation-tools/.config/znt/n-history.conf
213index 5d4bad822e3aaa696d81a45fa72d0bc4c9e6f64d..d7c69e1548414ce2f20d5ac65c0f658d0921c8a0 100644
214--- a/plugins/zsh-navigation-tools/.config/znt/n-history.conf
215+++ b/plugins/zsh-navigation-tools/.config/znt/n-history.conf
216@@ -1,10 +1,43 @@
217 # How should be current element of the list drawn. Possible values: reverse,
218-# underline. Default (without option set) is reverse
219+# underline.
220 # On Linux virtual terminal this will be enforced to reverse (because of poor
221-# underline support on that terminal)
222+# underline support on that terminal). The same for screen/tmux.
223 local active_text=underline
224
225 # Highlight a few keywords
226 local NLIST_COLORING_PATTERN="(while|for |sudo|make|(#s)git|vim(#e)|vim |emacs(#e)|emacs )"
227 local NLIST_COLORING_COLOR=$'\x1b[00;33m'
228 local NLIST_COLORING_MATCH_MULTIPLE=1
229+
230+# Search keywords, iterated with F2 or Ctrl-X or Ctrl-/
231+local -a keywords
232+keywords=( "git" "vim" "mplayer" )
233+
234+
235+
236+
237+
238+
239+
240+#
241+# Zshrc integration. All below variables can
242+# be set in zshrc and will have precedence
243+# over config files
244+#
245+
246+# 1. znt_history_active_text
247+active_text=${znt_history_active_text:-$active_text}
248+
249+# 2. znt_history_nlist_coloring_pattern
250+NLIST_COLORING_PATTERN=${znt_history_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
251+
252+# 3. znt_history_nlist_coloring_color
253+NLIST_COLORING_COLOR=${znt_history_nlist_coloring_color:-$NLIST_COLORING_COLOR}
254+
255+# 4. znt_history_nlist_coloring_match_multiple
256+NLIST_COLORING_MATCH_MULTIPLE=${znt_history_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
257+
258+# 5. znt_history_keywords (array)
259+if (( ${+znt_history_keywords} )); then
260+ keywords=( "${znt_history_keywords[@]}" )
261+fi
262diff --git a/plugins/zsh-navigation-tools/.config/znt/n-kill.conf b/plugins/zsh-navigation-tools/.config/znt/n-kill.conf
263index f1c4f02dad87f92dac066f21563fc07076268442..deb2a3fd998c28906a9625f6e19cde3d87427b94 100644
264--- a/plugins/zsh-navigation-tools/.config/znt/n-kill.conf
265+++ b/plugins/zsh-navigation-tools/.config/znt/n-kill.conf
266@@ -1,8 +1,8 @@
267 # How should be current element of the list drawn. Possible values: reverse,
268-# underline. Default (without option set) is reverse
269+# underline.
270 # On Linux virtual terminal this will be enforced to reverse (because of poor
271-# underline support on that terminal)
272-# local active_text=underline
273+# underline support on that terminal). The same for screen/tmux.
274+local active_text=reverse
275
276 # Colorize first number column and last path segment
277 # This doesn't cover scripts named "[0-9]## *", which should be very rare
278@@ -11,3 +11,36 @@
279 local NLIST_COLORING_PATTERN="((#s) #[0-9]## |[[][^]]#](#e)|[^ 0-9/?\\\\][^/\\\\]#(#e)|[^ /\\\\]##[^0-9/\\\\ ]##[^/\\\\]#(#e))"
280 local NLIST_COLORING_COLOR=$'\x1b[00;33m'
281 local NLIST_COLORING_MATCH_MULTIPLE=1
282+
283+# Search keywords, iterated with F2 or Ctrl-X or Ctrl-/
284+local -a keywords
285+keywords=( "vim" "git" "git commit" "firefox" "mplayer" )
286+
287+
288+
289+
290+
291+
292+
293+#
294+# Zshrc integration. All below variables can
295+# be set in zshrc and will have precedence
296+# over config files
297+#
298+
299+# 1. znt_kill_active_text
300+active_text=${znt_kill_active_text:-$active_text}
301+
302+# 2. znt_kill_nlist_coloring_pattern
303+NLIST_COLORING_PATTERN=${znt_kill_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
304+
305+# 3. znt_kill_nlist_coloring_color
306+NLIST_COLORING_COLOR=${znt_kill_nlist_coloring_color:-$NLIST_COLORING_COLOR}
307+
308+# 4. znt_kill_nlist_coloring_match_multiple
309+NLIST_COLORING_MATCH_MULTIPLE=${znt_kill_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
310+
311+# 5. znt_kill_keywords (array)
312+if (( ${+znt_kill_keywords} )); then
313+ keywords=( "${znt_kill_keywords[@]}" )
314+fi
315diff --git a/plugins/zsh-navigation-tools/.config/znt/n-list.conf b/plugins/zsh-navigation-tools/.config/znt/n-list.conf
316index cf9d2a3be95de2d002789e8a8a82672eb076f39d..68f5668f9f8f950f47979a0865b7264f727d1108 100644
317--- a/plugins/zsh-navigation-tools/.config/znt/n-list.conf
318+++ b/plugins/zsh-navigation-tools/.config/znt/n-list.conf
319@@ -1,3 +1,55 @@
320 # Should the list (text, borders) be drawn in bold
321 # Value 1 is the default
322-local bold=1
323+local bold=0
324+
325+# Main color pair (foreground/background)
326+local colorpair="white/black"
327+
328+# Should draw the border?
329+local border=1
330+
331+# Combinations of colors to try out with Ctrl-T and Ctrl-G
332+# The last number is the bold option, 0 or 1
333+local -a themes
334+themes=( "white/black/1" "green/black/0" "green/black/1" "white/blue/0" "white/blue/1"
335+ "magenta/black/0" "magenta/black/1" )
336+
337+# Uncomment when using new (>5.2) Zsh version that supports 256 colors in zcurses
338+#themes=( "white/17/0" "10/17/1" "white/24/1" "white/22/0" "white/22/1" "white/25/0" "white/25/1"
339+# "white/59/0" "white/59/1" "white/60/0" "white/60/1" "white/61/0" "white/61/1" "black/65/0"
340+# "black/244/0" )
341+
342+# When 1, pressing enter when in search mode will not
343+# only leave the mode, but also do selection and leave
344+# n-history
345+local NLIST_INSTANT_SELECT=0
346+
347+
348+
349+
350+
351+
352+
353+#
354+# Zshrc integration. All below variables can
355+# be set in zshrc and will have precedence
356+# over config files
357+#
358+
359+# 1. znt_list_bold
360+bold=${znt_list_bold:-$bold}
361+
362+# 2. znt_list_colorpair
363+colorpair=${znt_list_colorpair:-$colorpair}
364+
365+# 3. znt_list_border
366+border=${znt_list_border:-$border}
367+
368+# 4. znt_list_themes (array)
369+if (( ${+znt_list_themes} )); then
370+ themes=( "${znt_list_themes[@]}" )
371+fi
372+
373+# 5. znt_list_instant_select
374+NLIST_INSTANT_SELECT=${znt_list_instant_select:-$NLIST_INSTANT_SELECT}
375+
376diff --git a/plugins/zsh-navigation-tools/.config/znt/n-options.conf b/plugins/zsh-navigation-tools/.config/znt/n-options.conf
377index 98f4625f128fdba477edc7176f7c9c3b04309d69..29c5e089a71bf7da005db242e6523ed047858d28 100644
378--- a/plugins/zsh-navigation-tools/.config/znt/n-options.conf
379+++ b/plugins/zsh-navigation-tools/.config/znt/n-options.conf
380@@ -1,5 +1,34 @@
381 # How should be current element of the list drawn. Possible values: reverse,
382-# underline. Default (without option set) is reverse
383+# underline.
384 # On Linux virtual terminal this will be enforced to reverse (because of poor
385-# underline support on that terminal)
386-# local active_text=underline
387+# underline support on that terminal). The same for screen/tmux.
388+local active_text=reverse
389+
390+
391+
392+
393+
394+
395+
396+#
397+# Zshrc integration. All below variables can
398+# be set in zshrc and will have precedence
399+# over config files
400+#
401+
402+# 1. znt_options_active_text
403+active_text=${znt_options_active_text:-$active_text}
404+
405+# 2. znt_options_nlist_coloring_pattern
406+NLIST_COLORING_PATTERN=${znt_options_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
407+
408+# 3. znt_options_nlist_coloring_color
409+NLIST_COLORING_COLOR=${znt_options_nlist_coloring_color:-$NLIST_COLORING_COLOR}
410+
411+# 4. znt_options_nlist_coloring_match_multiple
412+NLIST_COLORING_MATCH_MULTIPLE=${znt_options_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
413+
414+# 5. znt_options_keywords (array)
415+if (( ${+znt_options_keywords} )); then
416+ keywords=( "${znt_options_keywords[@]}" )
417+fi
418diff --git a/plugins/zsh-navigation-tools/.config/znt/n-panelize.conf b/plugins/zsh-navigation-tools/.config/znt/n-panelize.conf
419index 98f4625f128fdba477edc7176f7c9c3b04309d69..58ce1b620795c525e7011679ca22d9c0b61ddc75 100644
420--- a/plugins/zsh-navigation-tools/.config/znt/n-panelize.conf
421+++ b/plugins/zsh-navigation-tools/.config/znt/n-panelize.conf
422@@ -1,5 +1,34 @@
423 # How should be current element of the list drawn. Possible values: reverse,
424-# underline. Default (without option set) is reverse
425+# underline.
426 # On Linux virtual terminal this will be enforced to reverse (because of poor
427-# underline support on that terminal)
428-# local active_text=underline
429+# underline support on that terminal). The same for screen/tmux.
430+local active_text=reverse
431+
432+
433+
434+
435+
436+
437+
438+#
439+# Zshrc integration. All below variables can
440+# be set in zshrc and will have precedence
441+# over config files
442+#
443+
444+# 1. znt_panelize_active_text
445+active_text=${znt_panelize_active_text:-$active_text}
446+
447+# 2. znt_panelize_nlist_coloring_pattern
448+NLIST_COLORING_PATTERN=${znt_panelize_nlist_coloring_pattern:-$NLIST_COLORING_PATTERN}
449+
450+# 3. znt_panelize_nlist_coloring_color
451+NLIST_COLORING_COLOR=${znt_panelize_nlist_coloring_color:-$NLIST_COLORING_COLOR}
452+
453+# 4. znt_panelize_nlist_coloring_match_multiple
454+NLIST_COLORING_MATCH_MULTIPLE=${znt_panelize_nlist_coloring_match_multiple:-$NLIST_COLORING_MATCH_MULTIPLE}
455+
456+# 5. znt_panelize_keywords (array)
457+if (( ${+znt_panelize_keywords} )); then
458+ keywords=( "${znt_panelize_keywords[@]}" )
459+fi
460diff --git a/plugins/zsh-navigation-tools/README.md b/plugins/zsh-navigation-tools/README.md
461index 32a86bba91d0b7e7fa49a87584b7c3cd32d049b8..7a679fe671dc88b6a4f5719f2f116de89531e0c6 100644
462--- a/plugins/zsh-navigation-tools/README.md
463+++ b/plugins/zsh-navigation-tools/README.md
464@@ -1,6 +1,6 @@
465 # Zsh Navigation Tools
466
467-http://imageshack.com/a/img633/7967/ps6rKR.png
468+https://raw.githubusercontent.com/psprint/zsh-navigation-tools/master/doc/img/n-history2.png
469
470 Set of tools like n-history – multi-word history searcher, n-cd – directory
471 bookmark manager, n-kill – htop like kill utility, and more. Based on
472@@ -32,6 +32,26 @@ to key combinations (no need for autoload when using Oh My Zsh):
473 Oh My Zsh stores history into ~/.zsh_history. When you switch to OMZ you could
474 want to copy your previous data (from e.g. ~/.zhistory) into the new location.
475
476+## News
477+
478+* 30-04-2016
479+ - New feature: color themes. Use Ctrl-T and Ctrl-G to browse predefined
480+ themes. They are listed in ~/.config/znt/n-list.conf. Use the file to
481+ permanently set a color scheme. Also, I sent a patch to Zsh developers
482+ and starting from Zsh > 5.2 (not yet released) supported will be 256 colors.
483+ The file ~/.config/znt/n-list.conf already has set of 256-color themes prepared :)
484+
485+* 29-04-2016
486+ - New feature: private history – n-history tracks selected history entries,
487+ exposes them via new view (activated with F1)
488+
489+* 28-04-2016
490+ - New features:
491+ 1. New n-history view (activated with F1): Most Frequent History Words
492+ 2. Predefined search keywords – use F2 to quickly search for chosen
493+ keywords (video: [https://youtu.be/DN9QqssAYB8](https://youtu.be/DN9QqssAYB8))
494+ 3. Configuration option for doing instant selection in search mode
495+
496 ## Introduction
497
498 The tools are:
499@@ -60,6 +80,65 @@ cursors. Other keys are:
500 - Ctrl-w (in incremental search) - delete whole word
501 - Ctrl-k (in incremental search) - delete whole line
502
503+## Configuration
504+
505+`ZNT` has configuration files located in `~/.config/znt`. The files are:
506+
507+```
508+n-aliases.conf
509+n-cd.conf
510+n-env.conf
511+n-functions.conf
512+n-history.conf
513+n-kill.conf
514+n-list.conf
515+n-options.conf
516+n-panelize.conf
517+```
518+
519+`n-list.conf` contains main configuration variables:
520+
521+```zsh
522+# Should the list (text, borders) be drawn in bold
523+local bold=0
524+
525+# Main color pair (foreground/background)
526+local colorpair="white/black"
527+
528+# Should draw the border?
529+local border=1
530+
531+# Combinations of colors to try out with Ctrl-T and Ctrl-G
532+# The last number is the bold option, 0 or 1
533+local -a themes
534+themes=( "white/black/1" "green/black/0" "green/black/1" "white/blue/0" "white/blue/1"
535+ "magenta/black/0" "magenta/black/1" )
536+```
537+
538+Read remaining configuration files to see what's in them. Nevertheless, configuration
539+can be also set from `zshrc`. There are `5` standard `zshrc` configuration variables:
540+
541+```
542+znt_history_active_text - underline or reverse - how should be active element highlighted
543+znt_history_nlist_coloring_pattern - pattern that can be used to colorize elements
544+znt_history_nlist_coloring_color - color with which to colorize
545+znt_history_nlist_coloring_match_multiple - should multiple matches be colorized (0 or 1)
546+znt_history_keywords (array) - search keywords activated with `Ctrl-X`
547+```
548+
549+Above variables will work for `n-history` tool. For other tools, change `_history_` to
550+e.g. `_cd_`, for the `n-cd` tool. The same works for all `8` tools.
551+
552+Common configuration of the tools uses variables with `_list_` in them:
553+
554+```
555+znt_list_bold - should draw text in bold (0 or 1)
556+znt_list_colorpair - main pair of colors to be used, e.g "green/black"
557+znt_list_border - should draw borders around windows (0 or 1)
558+znt_list_themes (array) - list of themes to try out with Ctrl-T, e.g. ( "white/black/1" "green/black/0" )
559+znt_list_instant_select - should pressing enter in search mode leave tool (0 or 1)
560+```
561+
562 ## Programming
563
564diff --git a/plugins/zsh-navigation-tools/_n-kill b/plugins/zsh-navigation-tools/_n-kill
565new file mode 100644
566index 0000000000000000000000000000000000000000..8a4ec9da711cfda4610a40d6466af012cef05c9c
567--- /dev/null
568+++ b/plugins/zsh-navigation-tools/_n-kill
569@@ -0,0 +1,41 @@
570+#compdef n-kill
571+
572+local context ret=1
573+
574+typeset -a list linewords
575+typeset -aU words wordbits
576+local line word
577+integer cygwin=0
578+
579+local IFS="
580+"
581+
582+case "$(uname)" in
583+ CYGWIN*) list=( `command ps -Wa` ); cygwin=1 ;;
584+ *) list=( `command ps -o pid,uid,command -A` ) ;;
585+esac
586+
587+shift list
588+
589+IFS=" "
590+for line in "${list[@]}"; do
591+ linewords=( $=line )
592+ if [ "$cygwin" = "1" ]; then
593+ linewords=( "${(@)linewords[8,-1]}" )
594+ else
595+ linewords=( "${(@)linewords[3,-1]}" )
596+ fi
597+ for word in "${linewords[@]}"; do
598+ if [ "$cygwin" = "1" ]; then
599+ wordbits=( "${(@s:\:)word}" )
600+ else
601+ wordbits=( "${(@s:/:)word}" )
602+ fi
603+ words+=( "${wordbits[@]}" )
604+ done
605+done
606+
607+_wanted bits expl "Processes' name bits" \
608+ compadd "$@" -a - words && ret=0
609+
610+return "$ret"
611diff --git a/plugins/zsh-navigation-tools/n-aliases b/plugins/zsh-navigation-tools/n-aliases
612index d81db9253277ab36c2b12e733f51230d8dc9edd3..f8c1c3727c2c2e08bb980bd58e0a736d4fdacde1 100644
613--- a/plugins/zsh-navigation-tools/n-aliases
614+++ b/plugins/zsh-navigation-tools/n-aliases
615@@ -16,8 +16,8 @@ local IFS="
616
617 unset NLIST_COLORING_PATTERN
618
619-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
620-[ -f ~/.config/znt/n-aliases.conf ] && . ~/.config/znt/n-aliases.conf
621+[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
622+[ -f ~/.config/znt/n-aliases.conf ] && builtin source ~/.config/znt/n-aliases.conf
623
624 local list
625 local selected
626diff --git a/plugins/zsh-navigation-tools/n-cd b/plugins/zsh-navigation-tools/n-cd
627index b1ac5b1592599da160974fd6b2aecf65d5607cb6..48c6dbf4ecbc4d0b155c8f8d7a3b4d469680d4d4 100644
628--- a/plugins/zsh-navigation-tools/n-cd
629+++ b/plugins/zsh-navigation-tools/n-cd
630@@ -16,8 +16,8 @@ local IFS="
631 # Unset before configuration is read
632 unset NLIST_COLORING_PATTERN
633
634-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
635-[ -f ~/.config/znt/n-cd.conf ] && . ~/.config/znt/n-cd.conf
636+[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
637+[ -f ~/.config/znt/n-cd.conf ] && builtin source ~/.config/znt/n-cd.conf
638
639 local list
640 local selected
641@@ -53,13 +53,16 @@ if [ "$REPLY" -gt 0 ]; then
642
643 (( NCD_DONT_PUSHD )) && setopt NO_AUTO_PUSHD
644 cd "$selected"
645+ local code=$?
646 (( NCD_DONT_PUSHD )) && setopt AUTO_PUSHD
647
648- # ZLE?
649- if [ "${(t)CURSOR}" = "integer-local-special" ]; then
650- zle -M "You have selected $selected"
651- else
652- echo "You have selected $selected"
653+ if [ "$code" -eq "0" ]; then
654+ # ZLE?
655+ if [ "${(t)CURSOR}" = "integer-local-special" ]; then
656+ zle -M "You have selected $selected"
657+ else
658+ echo "You have selected $selected"
659+ fi
660 fi
661 else
662 [ "${(t)CURSOR}" = "integer-local-special" ] && zle redisplay
663diff --git a/plugins/zsh-navigation-tools/n-env b/plugins/zsh-navigation-tools/n-env
664index 612796c0062178dfac82173bb26c40e623dcb8b0..c003b63a861a176c67dea11a20a308d012cc1711 100644
665--- a/plugins/zsh-navigation-tools/n-env
666+++ b/plugins/zsh-navigation-tools/n-env
667@@ -15,8 +15,8 @@ zmodload zsh/curses
668 local IFS="
669 "
670
671-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
672-[ -f ~/.config/znt/n-env.conf ] && . ~/.config/znt/n-env.conf
673+[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
674+[ -f ~/.config/znt/n-env.conf ] && builtin source ~/.config/znt/n-env.conf
675
676 local list
677 local selected
678diff --git a/plugins/zsh-navigation-tools/n-functions b/plugins/zsh-navigation-tools/n-functions
679index 6f10a3dece90372c34578bfce3304409aeecb424..1748cbc903ba9bdff740995c258ccbb7609fff89 100644
680--- a/plugins/zsh-navigation-tools/n-functions
681+++ b/plugins/zsh-navigation-tools/n-functions
682@@ -16,8 +16,8 @@ local IFS="
683
684 unset NLIST_COLORING_PATTERN
685
686-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
687-[ -f ~/.config/znt/n-functions.conf ] && . ~/.config/znt/n-functions.conf
688+[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
689+[ -f ~/.config/znt/n-functions.conf ] && builtin source ~/.config/znt/n-functions.conf
690
691 local list
692 local selected
693diff --git a/plugins/zsh-navigation-tools/n-help b/plugins/zsh-navigation-tools/n-help
694new file mode 100644
695index 0000000000000000000000000000000000000000..415050a81da68b8d08adb49a6195723a3357bcf8
696--- /dev/null
697+++ b/plugins/zsh-navigation-tools/n-help
698@@ -0,0 +1,96 @@
699+autoload colors
700+colors
701+
702+local h1="$fg_bold[cyan]"
703+local h2="$fg_bold[green]"
704+local h3="$fg_bold[blue]"
705+local h4="$fg_bold[yellow]"
706+local h5="$fg_bold[magenta]"
707+local rst="$reset_color"
708+
709+LESS="-iRc" less <<<"
710+${h1}Key Bindings${rst}
711+
712+${h2}H${rst}, ${h2}?${rst} (from n-history) - run n-help
713+${h2}Ctrl-A${rst} - rotate entered words (1+2+3 -> 3+1+2)
714+${h2}Ctrl-F${rst} - fix mode (approximate matching)
715+${h2}Ctrl-L${rst} - redraw of whole display
716+${h2}Ctrl-T${rst} - browse themes (next theme)
717+${h2}Ctrl-G${rst} - browse themes (previous theme)
718+${h2}Ctrl-U${rst} - half page up
719+${h2}Ctrl-D${rst} - half page down
720+${h2}Ctrl-P${rst} - previous element (also done with vim's k)
721+${h2}Ctrl-N${rst} - next element (also done with vim's j)
722+${h2}[${rst}, ${h2}]${rst} - jump directory bookmarks in n-cd and typical signals in n-kill
723+${h2}g, ${h2}G${rst} - beginning and end of the list
724+${h2}/${rst} - show incremental search
725+${h2}F3${rst} - show/hide incremental search
726+${h2}Esc${rst} - exit incremental search, clearing filter
727+${h2}Ctrl-W${rst} (in incremental search) - delete whole word
728+${h2}Ctrl-K${rst} (in incremental search) - delete whole line
729+${h2}Ctrl-O, ${h2}o${rst} - enter uniq mode (no duplicate lines)
730+${h2}Ctrl-E, ${h2}e${rst} - edit private history (when in private history view)
731+${h2}F1${rst} - (in n-history) - switch view
732+${h2}F2${rst}, ${h2}Ctrl-X${rst}, ${h2}Ctrl-/${rst} - search predefined keywords (defined in config files)
733+
734+${h1}Configuration files${rst}
735+
736+Location of the files is ${h3}~/.config/znt${rst}. Skeletons are copied there
737+when using ${h3}zsh-navigation-tools.plugin.zsh${rst} file (sourcing it or using
738+a plugin manager). There's a main config file ${h3}n-list.conf${rst} and files
739+for each tool.
740+
741+To have a skeleton copied again into ${h3}~/.config/znt${rst}, delete it from
742+there and restart Zsh a few times (3-7 or so; there's a random check
743+that optimizes startup time).
744+
745+${h1}Predefined search keywords${rst}
746+
747+Following block of code in e.g. ${h3}~/.config/znt/n-history.conf${rst} defines
748+set of keywords that can be invoked (i.e. searched for) via ${h2}F2${rst}, ${h2}Ctrl-X${rst}
749+or ${h2}Ctrl-/${rst}:
750+
751+ ${h4}# Search keywords, iterated with F2 or Ctrl-X or Ctrl-/${rst}
752+ ${h2}local${rst} -a keywords
753+ keywords=( ${h2}\"git\" \"vim\" \"mplayer\"${rst} )
754+
755+${h1}Search query rotation${rst}
756+
757+When searching, after pressing ${h2}Ctrl-A${rst}, words 1 2 3 will become 3 1 2, etc.
758+This can be used to edit some not-last word.
759+
760+${h1}Fix mode${rst}
761+
762+Approximate matching - pressing ${h2}f${rst} or ${h2}Ctrl-F${rst} will enter "FIX" mode, in which
763+1 or 2 errors are allowed in what's searched. This utilizes original Zsh
764+approximate matching features and is intended to be used after entering
765+search query, when a typo is discovered.
766+
767+${h1}Color themes${rst}
768+
769+Following block of code in ${h3}~/.config/znt/n-list.conf${rst} defines set of
770+themes that can be browsed with ${h2}Ctrl-T${rst} and ${h2}Ctrl-G${rst}:
771+
772+ ${h4}# Combinations of colors to try out with Ctrl-T and Ctrl-G
773+ # The last number is the bold option, 0 or 1${rst}
774+ ${h2}local${rst} -a themes
775+ themes=( ${h2}\"white/black/1\" \"green/black/0\" \"green/black/1\"${rst}
776+ ${h2}\"white/blue/0\" \"white/blue/1\" \"magenta/black/0\"${rst}
777+ ${h2}\"magenta/black/1\"${rst} )
778+
779+It's \"foreground/background/bold\". There's support for 256-color themes
780+for Zsh > 5.2, defined like e.g.:
781+
782+ themes=( ${h2}\"white/17/0\" \"10/17/1\" \"white/24/1\"${rst} )
783+
784+i.e. with use of numbers, from 0 to 254.
785+
786+${h1}Private history${rst}
787+
788+N-history stores what's selected in its own history file. It can be
789+edited. Use ${h2}e${rst} or ${h2}Ctrl-E${rst} for that when in n-history. Your \$EDITOR will
790+start. This is a way to have handy set of bookmarks prepared in private
791+history's file.
792+
793+Private history is instantly shared among sessions.
794+"
795diff --git a/plugins/zsh-navigation-tools/n-history b/plugins/zsh-navigation-tools/n-history
796index 9f1d6279ba62a8ab6b125be68d78948fe9345747..68370f6e5381a9b3383357b6665c7dbf1e736e00 100644
797--- a/plugins/zsh-navigation-tools/n-history
798+++ b/plugins/zsh-navigation-tools/n-history
799@@ -15,27 +15,323 @@ zmodload zsh/parameter
800 local IFS="
801 "
802
803-unset NLIST_COLORING_PATTERN
804+# Variables to save list's state when switching views
805+# The views are: history and "most frequent history words"
806+local one_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN
807+local one_NLIST_CURRENT_IDX
808+local one_NLIST_IS_SEARCH_MODE
809+local one_NLIST_SEARCH_BUFFER
810+local one_NLIST_TEXT_OFFSET
811+local one_NLIST_IS_UNIQ_MODE
812+local one_NLIST_IS_F_MODE
813+local one_NLIST_GREP_STRING
814+local one_NLIST_NONSELECTABLE_ELEMENTS
815+local one_NLIST_REMEMBER_STATE
816+local one_NLIST_ENABLED_EVENTS
817
818-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
819-[ -f ~/.config/znt/n-history.conf ] && . ~/.config/znt/n-history.conf
820+local two_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN
821+local two_NLIST_CURRENT_IDX
822+local two_NLIST_IS_SEARCH_MODE
823+local two_NLIST_SEARCH_BUFFER
824+local two_NLIST_TEXT_OFFSET
825+local two_NLIST_IS_UNIQ_MODE
826+local two_NLIST_IS_F_MODE
827+local two_NLIST_GREP_STRING
828+local two_NLIST_NONSELECTABLE_ELEMENTS
829+local two_NLIST_REMEMBER_STATE
830+local two_NLIST_ENABLED_EVENTS
831
832-local list
833-local selected
834+local three_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN
835+local three_NLIST_CURRENT_IDX
836+local three_NLIST_IS_SEARCH_MODE
837+local three_NLIST_SEARCH_BUFFER
838+local three_NLIST_TEXT_OFFSET
839+local three_NLIST_IS_UNIQ_MODE
840+local three_NLIST_IS_F_MODE
841+local three_NLIST_GREP_STRING
842+local three_NLIST_NONSELECTABLE_ELEMENTS
843+local three_NLIST_REMEMBER_STATE
844+local three_NLIST_ENABLED_EVENTS
845
846-NLIST_REMEMBER_STATE=0
847+# history view
848+integer active_view=0
849
850-list=( "$history[@]" )
851-list=( "${(@M)list:#(#i)*$1*}" )
852+# Lists are "0", "1", "2" - 1st, 2nd, 3rd
853+# Switching is done in cyclic manner
854+# i.e. 0 -> 1, 1 -> 2, 2 -> 0
855+_nhistory_switch_lists_states() {
856+ # First argument is current, newly selected list, i.e. $active_view
857+ # This implies that we are switching from previous view
858+
859+ if [ "$1" = "0" ]; then
860+ # Switched to 1st list, save 3rd list's state
861+ three_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN
862+ three_NLIST_CURRENT_IDX=$NLIST_CURRENT_IDX
863+ three_NLIST_IS_SEARCH_MODE=$NLIST_IS_SEARCH_MODE
864+ three_NLIST_SEARCH_BUFFER=$NLIST_SEARCH_BUFFER
865+ three_NLIST_TEXT_OFFSET=$NLIST_TEXT_OFFSET
866+ three_NLIST_IS_UNIQ_MODE=$NLIST_IS_UNIQ_MODE
867+ three_NLIST_IS_F_MODE=$NLIST_IS_F_MODE
868+ three_NLIST_GREP_STRING=$NLIST_GREP_STRING
869+ three_NLIST_NONSELECTABLE_ELEMENTS=( ${NLIST_NONSELECTABLE_ELEMENTS[@]} )
870+ three_NLIST_REMEMBER_STATE=$NLIST_REMEMBER_STATE
871+ three_NLIST_ENABLED_EVENTS=( ${NLIST_ENABLED_EVENTS[@]} )
872
873-if [ "$#list" -eq 0 ]; then
874- echo "No matching history entries"
875- return 1
876-fi
877+ # ..and restore 1st list's state
878+ NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=$one_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN
879+ NLIST_CURRENT_IDX=$one_NLIST_CURRENT_IDX
880+ NLIST_IS_SEARCH_MODE=$one_NLIST_IS_SEARCH_MODE
881+ NLIST_SEARCH_BUFFER=$one_NLIST_SEARCH_BUFFER
882+ NLIST_TEXT_OFFSET=$one_NLIST_TEXT_OFFSET
883+ NLIST_IS_UNIQ_MODE=$one_NLIST_IS_UNIQ_MODE
884+ NLIST_IS_F_MODE=$one_NLIST_IS_F_MODE
885+ NLIST_GREP_STRING=$one_NLIST_GREP_STRING
886+ NLIST_NONSELECTABLE_ELEMENTS=( ${one_NLIST_NONSELECTABLE_ELEMENTS[@]} )
887+ NLIST_REMEMBER_STATE=$one_NLIST_REMEMBER_STATE
888+ NLIST_ENABLED_EVENTS=( ${one_NLIST_ENABLED_EVENTS[@]} )
889+ elif [ "$1" = "1" ]; then
890+ # Switched to 2nd list, save 1st list's state
891+ one_NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN
892+ one_NLIST_CURRENT_IDX=$NLIST_CURRENT_IDX
893+ one_NLIST_IS_SEARCH_MODE=$NLIST_IS_SEARCH_MODE
894+ one_NLIST_SEARCH_BUFFER=$NLIST_SEARCH_BUFFER
895+ one_NLIST_TEXT_OFFSET=$NLIST_TEXT_OFFSET
896+ one_NLIST_IS_UNIQ_MODE=$NLIST_IS_UNIQ_MODE
897+ one_NLIST_IS_F_MODE=$NLIST_IS_F_MODE
898+ one_NLIST_GREP_STRING=$NLIST_GREP_STRING
899diff --git a/plugins/zsh-navigation-tools/n-kill b/plugins/zsh-navigation-tools/n-kill
900index e520822825450229a1e7400a77345119865c4a8c..0d10565e4f9b1ce45d7474a845842c0e04dbc51c 100644
901--- a/plugins/zsh-navigation-tools/n-kill
902+++ b/plugins/zsh-navigation-tools/n-kill
903@@ -13,8 +13,8 @@ zmodload zsh/curses
904 local IFS="
905 "
906
907-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
908-[ -f ~/.config/znt/n-kill.conf ] && . ~/.config/znt/n-kill.conf
909+[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
910+[ -f ~/.config/znt/n-kill.conf ] && builtin source ~/.config/znt/n-kill.conf
911
912 typeset -A signals
913 signals=(
914diff --git a/plugins/zsh-navigation-tools/n-list b/plugins/zsh-navigation-tools/n-list
915index 50159b4a016ee6cc2d14fefae98defc743910b12..d3a8da302ee40dedf1e77edb6a0183038a4a59aa 100644
916--- a/plugins/zsh-navigation-tools/n-list
917+++ b/plugins/zsh-navigation-tools/n-list
918@@ -29,7 +29,7 @@ _nlist_exit() {
919 setopt localoptions
920 setopt extendedglob
921
922- [[ "$REPLY" = -(#c0,1)[0-9]## ]] || REPLY="-1"
923+ [[ "$REPLY" = -(#c0,1)[0-9]## || "$REPLY" = F<-> || "$REPLY" = "EDIT" || "$REPLY" = "HELP" ]] || REPLY="-1"
924 zcurses 2>/dev/null delwin inner
925 zcurses 2>/dev/null delwin main
926 zcurses 2>/dev/null refresh
927@@ -167,6 +167,26 @@ integer prev_uniq_mode=0
928 integer prev_start_idx=-1
929 local MBEGIN MEND MATCH mbegin mend match
930
931+# Iteration over predefined keywords
932+integer curkeyword nkeywords
933+local keywordisfresh="0"
934+if [[ "${(t)keywords}" != *array* ]]; then
935+ local -a keywords
936+ keywords=()
937+fi
938+curkeyword=0
939+nkeywords=${#keywords}
940+
941+# Iteration over themes
942+integer curtheme nthemes
943+local themeisfresh="0"
944+if [[ "${(t)themes}" != *array* ]]; then
945+ local -a themes
946+ themes=()
947+fi
948+curtheme=0
949+nthemes=${#themes}
950+
951 # Ability to remember the list between calls
952 if [[ -z "$NLIST_REMEMBER_STATE" || "$NLIST_REMEMBER_STATE" -eq 0 || "$NLIST_REMEMBER_STATE" -eq 2 ]]; then
953 NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN=1
954@@ -175,6 +195,7 @@ if [[ -z "$NLIST_REMEMBER_STATE" || "$NLIST_REMEMBER_STATE" -eq 0 || "$NLIST_REM
955 NLIST_SEARCH_BUFFER=""
956 NLIST_TEXT_OFFSET=0
957 NLIST_IS_UNIQ_MODE=0
958+ NLIST_IS_F_MODE=0
959
960 # Zero - because it isn't known, unless we
961 # confirm that first element is selectable
962@@ -207,12 +228,19 @@ zcurses delwin main 2>/dev/null
963 zcurses delwin inner 2>/dev/null
964 zcurses addwin main "$term_height" "$term_width" 0 0
965 zcurses addwin inner "$inner_height" "$inner_width" 1 2
966-zcurses bg main white/black
967-zcurses bg inner white/black
968+# From n-list.conf
969+[ "$colorpair" = "" ] && colorpair="white/black"
970+[ "$border" = "0" ] || border="1"
971+local background="${colorpair#*/}"
972+local backuptheme="$colorpair/$bold"
973+zcurses bg main "$colorpair"
974+zcurses bg inner "$colorpair"
975 if [ "$NLIST_IS_SEARCH_MODE" -ne 1 ]; then
976 _nlist_cursor_visibility 0
977 fi
978
979+zcurses refresh
980+
981 #
982 # Listening for input
983 #
984@@ -237,9 +265,12 @@ while (( 1 )); do
985 # Do searching (filtering with string)
986 if [ -n "$NLIST_SEARCH_BUFFER" ]; then
987 # Compute new list?
988- if [[ "$NLIST_SEARCH_BUFFER" != "$prev_search_buffer" || "$NLIST_IS_UNIQ_MODE" -ne "$prev_uniq_mode" ]]; then
989+ if [[ "$NLIST_SEARCH_BUFFER" != "$prev_search_buffer" || "$NLIST_IS_UNIQ_MODE" -ne "$prev_uniq_mode"
990+ || "$NLIST_IS_F_MODE" -ne "$prev_f_mode" ]]
991+ then
992 prev_search_buffer="$NLIST_SEARCH_BUFFER"
993 prev_uniq_mode="$NLIST_IS_UNIQ_MODE"
994+ prev_f_mode="$NLIST_IS_F_MODE"
995 # regenerating list -> regenerating disp_list
996 prev_start_idx=-1
997
998@@ -251,7 +282,9 @@ while (( 1 )); do
999
1000 # Remove non-selectable elements
1001 [ "$#NLIST_NONSELECTABLE_ELEMENTS" -gt 0 ] && for i in "${(nO)NLIST_NONSELECTABLE_ELEMENTS[@]}"; do
1002- list[$i]=()
1003+ if [[ "$i" = <-> ]]; then
1004+ list[$i]=()
1005+ fi
1006 done
1007
1008 # Remove duplicates
1009@@ -266,13 +299,22 @@ while (( 1 )); do
1010 local search_pattern=""
1011 local colsearch_pattern=""
1012 if [ -n "$search_buffer" ]; then
1013- # Patterns will be *foo*~^*bar* and (foo|bar)
1014- search_pattern="${search_buffer// ##/*~^*}"
1015- colsearch_pattern="${search_buffer// ##/|}"
1016-
1017 # The repeat will make the matching work on a fresh heap
1018diff --git a/plugins/zsh-navigation-tools/n-list-draw b/plugins/zsh-navigation-tools/n-list-draw
1019index 2f8b1d0d5838a29c6bd264633ec06ed52090e081..ae1e0115fc05da6a7449b16e2303066bc92c6786 100644
1020--- a/plugins/zsh-navigation-tools/n-list-draw
1021+++ b/plugins/zsh-navigation-tools/n-list-draw
1022@@ -79,9 +79,9 @@ _nlist_print_with_ansi() {
1023
1024 if (( no_match == 0 )); then
1025 if (( col >= 30 && col <= 37 )); then
1026- zcurses attr "$win" $c[col-29]/black
1027+ zcurses attr "$win" $c[col-29]/"$background"
1028 elif [[ "$col" -eq 0 ]]; then
1029- zcurses attr "$win" white/black
1030+ zcurses attr "$win" "$colorpair"
1031 fi
1032 fi
1033 done
1034@@ -97,17 +97,19 @@ local win="$7"
1035 shift 7
1036 integer max_text_len=page_width-x_offset
1037
1038-[ "$bold" = "0" ] && bold="" || bold="+bold"
1039+[[ "$bold" = "0" || "$bold" = "-bold" ]] && bold="-bold" || bold="+bold"
1040 [[ "$active_text" = "underline" || "$active_text" = "reverse" ]] || local active_text="reverse"
1041-# With Linux terminal underline won't work properly
1042-[ "$TERM" = "linux" ] && active_text="reverse"
1043+# Linux has ncv 18, screen* has ncv 3 - underline won't work properly
1044+(( ${terminfo[ncv]:-0} & 2 )) && active_text="reverse"
1045+# FreeBSD uses TERM=xterm for newcons but doesn't actually support underline
1046+[[ "$TERM" = "xterm" && -z "$DISPLAY" ]] && active_text="reverse"
1047
1048 integer max_idx=page_height
1049 integer end_idx=max_idx
1050 [ "$end_idx" -gt "$#" ] && end_idx="$#"
1051 integer y=y_offset
1052
1053-zcurses attr "$win" $bold white/black
1054+zcurses attr "$win" "$bold" "$colorpair"
1055
1056 integer i text_len
1057 local text
1058diff --git a/plugins/zsh-navigation-tools/n-list-input b/plugins/zsh-navigation-tools/n-list-input
1059index 957cd5a0b134f5984d2124c52b8d564e219f2f1f..9bafc51b6bfcad5228d03d0ff924acdf517496c8 100644
1060--- a/plugins/zsh-navigation-tools/n-list-input
1061+++ b/plugins/zsh-navigation-tools/n-list-input
1062@@ -14,6 +14,52 @@ _nlist_compute_first_to_show_idx() {
1063 from_what_idx_list_is_shown=0+((current_idx-1)/page_height)*page_height+1
1064 }
1065
1066+_nlist_update_from_keywords() {
1067+ keywordisfresh="1"
1068+ if [ "$nkeywords" -gt 0 ]; then
1069+ curkeyword=$(( (curkeyword+1) % (nkeywords+1) ))
1070+ if [ "$curkeyword" -eq "0" ]; then
1071+ buffer=""
1072+ else
1073+ buffer="${keywords[curkeyword]}"
1074+ fi
1075+ fi
1076+}
1077+
1078+_nlist_iterate_theme() {
1079+ themeisfresh="1"
1080+ if [ "$1" = "1" ]; then
1081+ curtheme=$(( (curtheme+1) % (nthemes+1) ))
1082+ else
1083+ curtheme=curtheme-1
1084+ [ "$curtheme" -lt 0 ] && curtheme=nthemes
1085+ fi
1086+
1087+ if [ "$nthemes" -gt 0 ]; then
1088+ local theme=${themes[curtheme]}
1089+ [ "$curtheme" -eq "0" ] && theme="$backuptheme"
1090+
1091+ colorpair="${theme%/*}"
1092+ bold="${theme##*/}"
1093+ background="${colorpair#*/}"
1094+ zcurses bg main "$colorpair"
1095+ zcurses bg inner "$colorpair"
1096+ fi
1097+}
1098+
1099+_nlist_rotate_buffer() {
1100+ setopt localoptions noglob
1101+
1102+ local -a words
1103+ words=( ${(s: :)buffer} )
1104+ words=( ${words[-1]} ${words[1,-2]} )
1105+
1106+ local space=""
1107+ [ "${buffer[-1]}" = " " ] && space=" "
1108+
1109+ buffer="${(j: :)words}$space"
1110+}
1111+
1112 typeset -ga reply
1113 reply=( -1 '' )
1114 integer current_idx="$1"
1115@@ -26,6 +72,7 @@ local key="$7"
1116 integer search="$8"
1117 local buffer="$9"
1118 integer uniq_mode="$10"
1119+integer f_mode="$11"
1120
1121 #
1122 # Listening for input
1123@@ -79,21 +126,36 @@ case "$key" in
1124 ${NLIST_NONSELECTABLE_ELEMENTS[(r)$current_idx]} != $current_idx ]]
1125 then
1126 # Save current element in the result variable
1127- reply=( $current_idx SELECT )
1128+ reply=( $current_idx "SELECT" )
1129+ fi
1130+ ;;
1131+ (H|'?')
1132+ # This event needs to be enabled
1133+ if [[ "${NLIST_ENABLED_EVENTS[(r)HELP]}" = "HELP" ]]; then
1134+ reply=( -1 "HELP" )
1135 fi
1136 ;;
1137+ (F1)
1138+ # This event needs to be enabled
1139+ if [[ "${NLIST_ENABLED_EVENTS[(r)F1]}" = "F1" ]]; then
1140+ reply=( -1 "$key" )
1141+ fi
1142+ ;;
1143+ (F4|F5|F6|F7|F8|F9|F10|DC)
1144+ # ignore; F2, F3 are used below
1145+ ;;
1146 (q)
1147- reply=( -1 QUIT )
1148+ reply=( -1 "QUIT" )
1149 ;;
1150 (/)
1151 search=1
1152 _nlist_cursor_visibility 1
1153 ;;
1154 ($'\t')
1155- reply=( $current_idx LEAVE )
1156+ reply=( $current_idx "LEAVE" )
1157 ;;
1158 ($'\C-L')
1159- reply=( -1 REDRAW )
1160+ reply=( -1 "REDRAW" )
1161 ;;
1162diff --git a/plugins/zsh-navigation-tools/n-options b/plugins/zsh-navigation-tools/n-options
1163index 91589bd455d4270bcb10631632f28b21dbf76327..b1a934015654971b207521a0b7bb85a5a4835742 100644
1164--- a/plugins/zsh-navigation-tools/n-options
1165+++ b/plugins/zsh-navigation-tools/n-options
1166@@ -14,8 +14,8 @@ local IFS="
1167
1168 unset NLIST_COLORING_PATTERN
1169
1170-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
1171-[ -f ~/.config/znt/n-options.conf ] && . ~/.config/znt/n-options.conf
1172+[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
1173+[ -f ~/.config/znt/n-options.conf ] && builtin source ~/.config/znt/n-options.conf
1174
1175 # TODO restore options
1176 unsetopt localoptions
1177diff --git a/plugins/zsh-navigation-tools/n-panelize b/plugins/zsh-navigation-tools/n-panelize
1178index 01d01cb9eba4219c5670b25b22b6b453028752f7..e2b567f2ef32538bd61ab86bb07a4be54bcad438 100644
1179--- a/plugins/zsh-navigation-tools/n-panelize
1180+++ b/plugins/zsh-navigation-tools/n-panelize
1181@@ -17,8 +17,8 @@ local IFS="
1182
1183 unset NLIST_COLORING_PATTERN
1184
1185-[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
1186-[ -f ~/.config/znt/n-panelize.conf ] && . ~/.config/znt/n-panelize.conf
1187+[ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
1188+[ -f ~/.config/znt/n-panelize.conf ] && builtin source ~/.config/znt/n-panelize.conf
1189
1190 local list
1191 local selected
1192diff --git a/plugins/zsh-navigation-tools/znt-history-widget b/plugins/zsh-navigation-tools/znt-history-widget
1193index a4a26cbfcb6005759584abfe019c6b908c1be647..479c2211bfd4a308f85f3b89c459f932f7cf4d37 100644
1194--- a/plugins/zsh-navigation-tools/znt-history-widget
1195+++ b/plugins/zsh-navigation-tools/znt-history-widget
1196@@ -4,6 +4,14 @@ local NLIST_START_IN_UNIQ_MODE=1
1197
1198 # Only if current $BUFFER doesn't come from history
1199 if [ "$HISTCMD" = "$HISTNO" ]; then
1200+ () {
1201+ setopt localoptions extendedglob
1202+ local -a match mbegin mend
1203+ local MATCH; integer MBEGIN MEND
1204+
1205+ [ -n "$BUFFER" ] && BUFFER="${BUFFER%% ##} "
1206+ }
1207+
1208 local NLIST_SET_SEARCH_TO="$BUFFER"
1209 fi
1210
1211diff --git a/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh b/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
1212index 4aa3aa4b8158c5fd768c0946a990c52e114a62be..b2654915202a385ff3cdf77576a87b4c04fb298d 100755
1213--- a/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
1214+++ b/plugins/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
1215@@ -15,13 +15,21 @@ if ! test -d "$CONFIG_DIR"; then
1216 mkdir "$CONFIG_DIR"
1217 fi
1218
1219+# 9 files
1220 set n-aliases.conf n-env.conf n-history.conf n-list.conf n-panelize.conf n-cd.conf n-functions.conf n-kill.conf n-options.conf
1221
1222-for i; do
1223- if ! test -f "$CONFIG_DIR/$i"; then
1224- cp "$REPO_DIR/.config/znt/$i" "$CONFIG_DIR"
1225- fi
1226-done
1227+# Check for random 2 files if they exist
1228+# This will shift 0 - 7 elements
1229+shift $(( RANDOM % 8 ))
1230+if ! test -f "$CONFIG_DIR/$1" || ! test -f "$CONFIG_DIR/$2"; then
1231+ # Something changed - examine every file
1232+ set n-aliases.conf n-env.conf n-history.conf n-list.conf n-panelize.conf n-cd.conf n-functions.conf n-kill.conf n-options.conf
1233+ for i; do
1234+ if ! test -f "$CONFIG_DIR/$i"; then
1235+ cp "$REPO_DIR/.config/znt/$i" "$CONFIG_DIR"
1236+ fi
1237+ done
1238+fi
1239
1240 # Don't leave positional parameters being set
1241 set --
1242@@ -30,12 +38,13 @@ set --
1243 # Load functions
1244 #
1245
1246-autoload n-aliases n-cd n-env n-functions n-history n-kill n-list n-list-draw n-list-input n-options n-panelize
1247+autoload n-aliases n-cd n-env n-functions n-history n-kill n-list n-list-draw n-list-input n-options n-panelize n-help
1248 autoload znt-usetty-wrapper znt-history-widget znt-cd-widget znt-kill-widget
1249 alias naliases=n-aliases ncd=n-cd nenv=n-env nfunctions=n-functions nhistory=n-history
1250-alias nkill=n-kill noptions=n-options npanelize=n-panelize
1251+alias nkill=n-kill noptions=n-options npanelize=n-panelize nhelp=n-help
1252
1253 zle -N znt-history-widget
1254 bindkey '^R' znt-history-widget
1255 setopt AUTO_PUSHD HIST_IGNORE_DUPS PUSHD_IGNORE_DUPS
1256+zstyle ':completion::complete:n-kill::bits' matcher 'r:|=** l:|=*'
1257