1HSTR(1) General Commands Manual HSTR(1)
2
3
4
6 hstr - easily view, navigate, sort and use your command history with
7 shell history suggest box.
8
10 hstr [option] [arg1] [arg2]...
11
13 hstr uses shell history to provide suggest box like functionality for
14 commands used in the past. By default it parses .bash-history file that
15 is filtered as you type a command substring. Commands are not just fil‐
16 tered, but also ordered by a ranking algorithm that considers number of
17 occurrences, length and timestamp. Favorite and frequently used com‐
18 mands can be bookmarked. In addition hstr allows removal of commands
19 from history - for instance with a typo or with a sensitive content.
20
22 -h --help
23 Show help
24
25 -n --non-interactive
26 Print filtered history on standard output and exit
27
28 -k --kill-last-command
29 Delete the last command from history and exit
30
31 -i --insert-in-terminal=[command]
32 Insert custom command to terminal prompt and exit
33
34 -f --favorites
35 Show favorites view immediately
36
37 -s --show-configuration
38 Show configuration to be added to the config file of the shell
39 (~/.bashrc or ~/.zshrc)
40
41 -B --show-bash-configuration
42 Show Bash configuration to be added to ~/.bashrc
43
44 -Z --show-zsh-configuration
45 Show Zsh configuration to be added to ~/.zshrc
46
47 -b --show-blacklist
48 Show blacklist of commands to be filtered out before history
49 processing
50
51 -V --version
52 Show version information
53
55 pattern
56 Type to filter shell history.
57
58 Ctrl-e Toggle regular expression and substring search.
59
60 Ctrl-t Toggle case sensitive search.
61
62 Ctrl-/, Ctrl-7
63 Rotate view of history as provided by bash, ranked history or‐
64 dered by the number of occurrences/length/timestamp and fa‐
65 vorites.
66
67 Ctrl-f Add currently selected command to favorites.
68
69 Ctrl-l Toggle search pattern case.
70
71 Ctrl-r, UP arrow, DOWN arrow, Ctrl-n, Ctrl-p, Ctrl-j, Ctrl-k
72 Navigate in the history list.
73
74 TAB, RIGHT arrow
75 Choose currently selected item for completion and let user to
76 edit it on the command prompt.
77
78 LEFT arrow
79 Choose currently selected item for completion and let user to
80 edit it in editor (fix command).
81
82 ENTER Choose currently selected item for completion and execute it.
83
84 DEL Remove currently selected item from the shell history.
85
86 BACKSPACE, Ctrl-h
87 Delete last pattern character.
88
89 Ctrl-u, Ctrl-w
90 Delete pattern and search again.
91
92 Ctrl-x Write changes to shell history and exit.
93
94 Ctrl-g Exit with empty prompt.
95
97 hstr defines the following environment variables:
98
99 HSTR_CONFIG
100 Configuration options:
101
102 hicolor
103 Get more colors with this option (default is monochro‐
104 matic).
105
106 monochromatic
107 Ensure black and white view.
108
109 prompt-bottom
110 Show prompt at the bottom of the screen (default is
111 prompt at the top).
112
113 help-on-opposite-side
114 Show help label on the opposite site (default is next to
115 the prompt).
116
117 hide-basic-help
118 Hide the basic help label.
119
120 hide-help
121 Hide basic and history help labels. Implicitly sets
122 hide-basic-help.
123
124 no-confirm
125 Do not ask for confirmation on a history entry delete
126 (default is with confirmation).
127
128 regexp-matching
129 Filter command history using regular expressions.
130
131 substring-matching
132 Filter command history using substring.
133
134 keywords-matching
135 Filter command history using keywords - item matches if
136 contains all keywords in pattern in any order (keywords match is
137 default).
138
139 case-sensitive
140 Make history filtering case sensitive (it's case insen‐
141 sitive by default).
142
143 raw-history-view
144 Show normal history as a default view (metric-based view
145 is shown otherwise).
146
147 favorites-view
148 Show favorites as a default view (metric-based view is
149 shown otherwise).
150
151 static-favorites
152 Do not put recently used favorite to the head of fa‐
153 vorites (favorites are reordered by default).
154
155 skip-favorites-comments
156 Skip comments (lines beginning with #) when loading
157 ~/.hstr_favorites (all lines are loaded by default).
158
159 duplicates
160 Show duplicates in rawhistory (duplicates are discarded
161 by default).
162
163 verbose-kill
164 Print the last command command deleted from history
165 (nothing is printed by default).
166
167 blacklist
168 Load list of commands to skip when processing history
169 from ~/.hstr_blacklist (built-in blacklist used otherwise).
170
171 keep-page
172 Don't clear page with command selection on exit (page is
173 cleared by default).
174
175 big-keys-skip
176 Skip big history entries i.e. very long lines (default).
177
178 big-keys-floor
179 Use different sorting slot for big keys when building
180 metrics-based view (big keys are skipped by default).
181
182 big-keys-exit
183 Exit (fail) on presence of a big key in history (big
184 keys are skipped by default).
185
186 warning
187 Show warning.
188
189 debug
190 Show debug information.
191
192 Example:
193 export HSTR_CONFIG=hicolor,regexp-matching,raw-history-
194 view
195
196
197 HSTR_PROMPT
198 Change prompt string which is user@host$ by default.
199
200 Example:
201 export HSTR_PROMPT="$ "
202
203
205 ~/.hstr_favorites
206 Bookmarked favorite commands.
207
208 ~/.hstr_blacklist
209 Commands to be hidden.
210
211
213 Add the following lines to ~/bashrc if TIOCSTI is not supported by your
214 OS:
215
216 alias hh=hstr # hh to be alias for hstr
217 export HSTR_CONFIG=hicolor # get more colors
218 shopt -s histappend # append new history items to .bash_history
219 export HISTCONTROL=ignorespace # leading space hides commands from history
220 export HISTFILESIZE=10000 # increase history file size (default is 500)
221 export HISTSIZE=${HISTFILESIZE} # increase history size (default is 500)
222 # ensure synchronization between bash memory and history file
223 export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
224 function hstrnotiocsti {
225 { HSTR_OUT="$( { </dev/tty hstr ${READLINE_LINE}; } 2>&1 1>&3 3>&- )"; } 3>&1;
226 READLINE_LINE="$(hstr ${READLINE_LINE})"
227 READLINE_POINT=${#READLINE_LINE}
228 }
229 # if this is interactive shell, then bind hstr to Ctrl-r (for Vi mode check doc)
230 if [[ $- =~ .*i.* ]]; then bind -x '""hstrnotiocsti"'; fi
231 export HSTR_TIOCSTI=n
232
233 Optionally add the following lines to ~/.bashrc if TIOCSTI is supported
234 by your OS:
235
236 alias hh=hstr # make hh alias of hstr
237 export HSTR_CONFIG=hicolor # get more colors
238 shopt -s histappend # append new history items to .bash_history
239 export HISTCONTROL=ignorespace # leading space hides commands from history
240 export HISTFILESIZE=10000 # increase history file size (default is 500)
241 export HISTSIZE=${HISTFILESIZE} # increase history size (default is 500)
242 # ensure synchronization between bash memory and history file
243 export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
244 # if this is interactive shell, then bind hstr to Ctrl-r (for Vi mode check doc)
245 if [[ $- =~ .*i.* ]]; then bind '"\C-r": "\C-a hstr -- \C-j"'; fi
246
247
249 Add the following lines to ~/zshrc if TIOCSTI is not supported by your
250 OS:
251
252 alias hh=hstr # hh to be alias for hstr
253 setopt histignorespace # skip cmds w/ leading space from history
254 export HSTR_CONFIG=hicolor # get more colors
255 hstr_no_tiocsti() {
256 zle -I
257 { HSTR_OUT="$( { </dev/tty hstr ${BUFFER}; } 2>&1 1>&3 3>&- )"; } 3>&1;
258 BUFFER="${HSTR_OUT}"
259 CURSOR=${#BUFFER}
260 zle redisplay
261 }
262 zle -N hstr_no_tiocsti
263 bindkey 'hstr_no_tiocsti
264 export HSTR_TIOCSTI=n
265
266 Optionally add the following lines to ~/.zshrc if TIOCSTI is supported
267 by your OS:
268
269 export HSTR_CONFIG=hicolor # get more colors
270 setopt histignorespace # skip cmds w/ leading space from history
271 bindkey -s "\C-r" "\C-a hstr -- \C-j" # bind hstr to Ctrl-r (for Vi mode check doc)
272
273
275 hstr git
276 Start hstr and show only history items containing 'git'.
277
278 hstr cpp add git
279 Start hstr and show only history items containing 'cpp', 'add'
280 and 'git'.
281
282 hstr --non-interactive git
283 Print history items containing 'git' to standard output and
284 exit.
285
286 hstr --show-configuration >> ~/.bashrc
287 Append default hstr configuration to your Bash profile.
288
289 hstr --show-configuration >> ~/.zhrc
290 Append default hstr configuration to your Zsh profile.
291
292 hstr --show-blacklist
293 Show blacklist configured for history processing.
294
295 hstr --insert-in-terminal="git add . && git diff --cached"
296 Insert command in terminal prompt and exit.
297
299 Written by Martin Dvorak <martin.dvorak@mindforger.com>
300
302 Report bugs to https://github.com/dvorka/hstr/issues
303
305 history(1), bash(1), zsh(1)
306
307
308
309 HSTR(1)