Diff
1diff --git a/plugins/zsh-navigation-tools/.config/znt/n-cd.conf b/plugins/zsh-navigation-tools/.config/znt/n-cd.conf
2index 5fcfe64fa36058b0f64dc2ced46fb4568c290c08..f8c49bfac019be65fe66524dcbceadc04fa2c8aa 100644
3--- a/plugins/zsh-navigation-tools/.config/znt/n-cd.conf
4+++ b/plugins/zsh-navigation-tools/.config/znt/n-cd.conf
5@@ -1,6 +1,7 @@
6 # Hotlist
7 local hotlist
8 hotlist=(
9+ ~/.config/znt
10 /usr/share/zsh/site-functions
11 /usr/share/zsh
12 /usr/local/share/zsh/site-functions
13diff --git a/plugins/zsh-navigation-tools/.config/znt/n-history.conf b/plugins/zsh-navigation-tools/.config/znt/n-history.conf
14index f798f71216df901dc2f22c701210e622fabeb85e..5d4bad822e3aaa696d81a45fa72d0bc4c9e6f64d 100644
15--- a/plugins/zsh-navigation-tools/.config/znt/n-history.conf
16+++ b/plugins/zsh-navigation-tools/.config/znt/n-history.conf
17@@ -3,3 +3,8 @@
18 # On Linux virtual terminal this will be enforced to reverse (because of poor
19 # underline support on that terminal)
20 local active_text=underline
21+
22+# Highlight a few keywords
23+local NLIST_COLORING_PATTERN="(while|for |sudo|make|(#s)git|vim(#e)|vim |emacs(#e)|emacs )"
24+local NLIST_COLORING_COLOR=$'\x1b[00;33m'
25+local NLIST_COLORING_MATCH_MULTIPLE=1
26diff --git a/plugins/zsh-navigation-tools/README.txt b/plugins/zsh-navigation-tools/README.md
27rename from plugins/zsh-navigation-tools/README.txt
28rename to plugins/zsh-navigation-tools/README.md
29index 4771742db58854bf04e1e06f0bd7a8a4a57689ec..686213c36836c7a5aff8257ab8cd5849b57f23e5 100644
30--- a/plugins/zsh-navigation-tools/README.txt
31+++ b/plugins/zsh-navigation-tools/README.md
32@@ -2,16 +2,17 @@
33
34 http://imageshack.com/a/img633/7967/ps6rKR.png
35
36-A tool generating a selectable curses-based list of elements that has access to
37-current Zsh session, i.e. has broad capabilities to work together with it.
38-That's n-list. The files n-cd, n-env, n-kill, etc. are applications of
39-the tool. Feature highlights include incremental multi-word searching, ANSI
40+Set of tools like n-history – multi-word history searcher, n-cd – directory
41+bookmark manager, n-kill – htop like kill utility, and more. Based on
42+n-list, a tool generating selectable curses-based list of elements that has
43+access to current Zsh session, i.e. has broad capabilities to work together
44+with it. Feature highlights include incremental multi-word searching, ANSI
45 coloring, unique mode, horizontal scroll, non-selectable elements, grepping and
46 various integrations with Zsh.
47
48 ## History Widget
49
50-To have n-history as the incremental searcher bound to Ctrl-R copy znt-*
51+To have n-history as multi-word incremental searcher bound to Ctrl-R copy znt-*
52 files into the */site-functions dir (unless you use Oh My Zsh) and
53 add:
54
55@@ -21,13 +22,16 @@ add:
56
57 to .zshrc. This is done automatically when using Oh My Zsh. Two other
58 widgets exist, znt-cd-widget and znt-kill-widget, they can be too assigned
59-to key combinations:
60+to key combinations (no need for autoload when using Oh My Zsh):
61
62 zle -N znt-cd-widget
63 bindkey "^T" znt-cd-widget
64 zle -N znt-kill-widget
65 bindkey "^Y" znt-kill-widget
66
67+Oh My Zsh stores history into ~/.zsh_history. When you switch to OMZ you could
68+want to copy your previous data (from e.g. ~/.zhistory) into the new location.
69+
70 ## Introduction
71
72 The tools are:
73@@ -99,3 +103,9 @@ expressions, (#s) is ^, (#e) is $, # is *, ## is +. Alternative
74 will work when in parenthesis, i.e. (a|b). BTW by using this method you can
75 colorize output of the tools, via their config files (check out e.g. n-cd.conf,
76 it uses this).
77+
78+## Performance
79+ZNT is fastest with Zsh before 5.0.8 and starting from 5.2 (the version yet to
80+be released).
81+
82+# vim:filetype=conf
83diff --git a/plugins/zsh-navigation-tools/n-history b/plugins/zsh-navigation-tools/n-history
84index e66f2a50a1801cacf265768c01d25b3a442ec73a..c9e53316beb5e0995bf22ea4134a2d7d82476e6f 100644
85--- a/plugins/zsh-navigation-tools/n-history
86+++ b/plugins/zsh-navigation-tools/n-history
87@@ -10,6 +10,7 @@ emulate -L zsh
88
89 setopt extendedglob
90 zmodload zsh/curses
91+zmodload zsh/parameter
92
93 local IFS="
94 "
95@@ -24,16 +25,16 @@ local selected
96
97 NLIST_REMEMBER_STATE=0
98
99-list=( `builtin history -rn 1` )
100+list=( "$history[@]" )
101 list=( "${(@M)list:#(#i)*$1*}" )
102
103-local NLIST_GREP_STRING="$1"
104-
105 if [ "$#list" -eq 0 ]; then
106 echo "No matching history entries"
107 return 1
108 fi
109
110+local NLIST_GREP_STRING="$1"
111+local NLIST_REPLACE_NEWLINES="1"
112 n-list "${list[@]}"
113
114 if [ "$REPLY" -gt 0 ]; then
115diff --git a/plugins/zsh-navigation-tools/n-list b/plugins/zsh-navigation-tools/n-list
116index 3b326515e0a0ec9bbfbbb5de588e8475cfb01760..c7066318edf58291d60ec791410eaa80081aadb1 100644
117--- a/plugins/zsh-navigation-tools/n-list
118+++ b/plugins/zsh-navigation-tools/n-list
119@@ -139,6 +139,7 @@ if [ "$#" -lt 1 ]; then
120 fi
121
122 REPLY="-1"
123+typeset -ga reply
124 reply=()
125
126 integer term_height="$LINES"
127@@ -188,6 +189,11 @@ if [ "$NLIST_START_IN_SEARCH_MODE" -eq 1 ]; then
128 NLIST_IS_SEARCH_MODE=1
129 fi
130
131+if [ -n "$NLIST_SET_SEARCH_TO" ]; then
132+ NLIST_SEARCH_BUFFER="$NLIST_SET_SEARCH_TO"
133+ NLIST_SET_SEARCH_TO=""
134+fi
135+
136 if [ "$NLIST_START_IN_UNIQ_MODE" -eq 1 ]; then
137 NLIST_START_IN_UNIQ_MODE=0
138 NLIST_IS_UNIQ_MODE=1
139@@ -281,6 +287,9 @@ while (( 1 )); do
140 if [ "$prev_start_idx" -ne "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" ]; then
141 prev_start_idx="$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN"
142 disp_list=( "${(@)col_list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" )
143+
144+ # We have display list, lets replace newlines with "\n" when needed (1/3)
145+ [ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" )
146 fi
147
148 # Output colored list
149@@ -333,11 +342,17 @@ while (( 1 )); do
150 if [ "$prev_start_idx" -ne "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" ]; then
151 prev_start_idx="$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN"
152 disp_list=( "${(@)list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" )
153+
154+ # We have display list, lets replace newlines with "\n" when needed (2/3)
155+ [ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" )
156 fi
157 else
158 if [ "$prev_start_idx" -ne "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" ]; then
159 prev_start_idx="$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN"
160 disp_list=( "${(@)col_list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" )
161+
162+ # We have display list, lets replace newlines with "\n" when needed (3/3)
163+ [ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" )
164 fi
165 fi
166
167diff --git a/plugins/zsh-navigation-tools/znt-history-widget b/plugins/zsh-navigation-tools/znt-history-widget
168index 097de8233ea51a15d80ffae6807a53a379ebc370..9ddae606d9163f7e4b61f048909fcd3854919698 100644
169--- a/plugins/zsh-navigation-tools/znt-history-widget
170+++ b/plugins/zsh-navigation-tools/znt-history-widget
171@@ -1,8 +1,10 @@
172 autoload znt-usetty-wrapper n-history
173 local NLIST_START_IN_SEARCH_MODE=1
174 local NLIST_START_IN_UNIQ_MODE=1
175+local NLIST_SET_SEARCH_TO="$BUFFER"
176
177 znt-usetty-wrapper n-history "$@"
178
179 unset NLIST_START_IN_SEARCH_MODE
180 unset NLIST_START_IN_UNIQ_MODE
181+unset NLIST_SET_SEARCH_TO