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/n-history b/plugins/zsh-navigation-tools/n-history
27index e66f2a50a1801cacf265768c01d25b3a442ec73a..c9e53316beb5e0995bf22ea4134a2d7d82476e6f 100644
28--- a/plugins/zsh-navigation-tools/n-history
29+++ b/plugins/zsh-navigation-tools/n-history
30@@ -10,6 +10,7 @@ emulate -L zsh
31
32 setopt extendedglob
33 zmodload zsh/curses
34+zmodload zsh/parameter
35
36 local IFS="
37 "
38@@ -24,16 +25,16 @@ local selected
39
40 NLIST_REMEMBER_STATE=0
41
42-list=( `builtin history -rn 1` )
43+list=( "$history[@]" )
44 list=( "${(@M)list:#(#i)*$1*}" )
45
46-local NLIST_GREP_STRING="$1"
47-
48 if [ "$#list" -eq 0 ]; then
49 echo "No matching history entries"
50 return 1
51 fi
52
53+local NLIST_GREP_STRING="$1"
54+local NLIST_REPLACE_NEWLINES="1"
55 n-list "${list[@]}"
56
57 if [ "$REPLY" -gt 0 ]; then
58diff --git a/plugins/zsh-navigation-tools/n-list b/plugins/zsh-navigation-tools/n-list
59index 3b326515e0a0ec9bbfbbb5de588e8475cfb01760..c7066318edf58291d60ec791410eaa80081aadb1 100644
60--- a/plugins/zsh-navigation-tools/n-list
61+++ b/plugins/zsh-navigation-tools/n-list
62@@ -139,6 +139,7 @@ if [ "$#" -lt 1 ]; then
63 fi
64
65 REPLY="-1"
66+typeset -ga reply
67 reply=()
68
69 integer term_height="$LINES"
70@@ -188,6 +189,11 @@ if [ "$NLIST_START_IN_SEARCH_MODE" -eq 1 ]; then
71 NLIST_IS_SEARCH_MODE=1
72 fi
73
74+if [ -n "$NLIST_SET_SEARCH_TO" ]; then
75+ NLIST_SEARCH_BUFFER="$NLIST_SET_SEARCH_TO"
76+ NLIST_SET_SEARCH_TO=""
77+fi
78+
79 if [ "$NLIST_START_IN_UNIQ_MODE" -eq 1 ]; then
80 NLIST_START_IN_UNIQ_MODE=0
81 NLIST_IS_UNIQ_MODE=1
82@@ -281,6 +287,9 @@ while (( 1 )); do
83 if [ "$prev_start_idx" -ne "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" ]; then
84 prev_start_idx="$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN"
85 disp_list=( "${(@)col_list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" )
86+
87+ # We have display list, lets replace newlines with "\n" when needed (1/3)
88+ [ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" )
89 fi
90
91 # Output colored list
92@@ -333,11 +342,17 @@ while (( 1 )); do
93 if [ "$prev_start_idx" -ne "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" ]; then
94 prev_start_idx="$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN"
95 disp_list=( "${(@)list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" )
96+
97+ # We have display list, lets replace newlines with "\n" when needed (2/3)
98+ [ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" )
99 fi
100 else
101 if [ "$prev_start_idx" -ne "$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN" ]; then
102 prev_start_idx="$NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN"
103 disp_list=( "${(@)col_list[NLIST_FROM_WHAT_IDX_LIST_IS_SHOWN, end_idx]}" )
104+
105+ # We have display list, lets replace newlines with "\n" when needed (3/3)
106+ [ "$NLIST_REPLACE_NEWLINES" -eq 1 ] && disp_list=( "${(@)disp_list//$'\n'/\\n}" )
107 fi
108 fi
109
110diff --git a/plugins/zsh-navigation-tools/znt-history-widget b/plugins/zsh-navigation-tools/znt-history-widget
111index 097de8233ea51a15d80ffae6807a53a379ebc370..9ddae606d9163f7e4b61f048909fcd3854919698 100644
112--- a/plugins/zsh-navigation-tools/znt-history-widget
113+++ b/plugins/zsh-navigation-tools/znt-history-widget
114@@ -1,8 +1,10 @@
115 autoload znt-usetty-wrapper n-history
116 local NLIST_START_IN_SEARCH_MODE=1
117 local NLIST_START_IN_UNIQ_MODE=1
118+local NLIST_SET_SEARCH_TO="$BUFFER"
119
120 znt-usetty-wrapper n-history "$@"
121
122 unset NLIST_START_IN_SEARCH_MODE
123 unset NLIST_START_IN_UNIQ_MODE
124+unset NLIST_SET_SEARCH_TO