xaizek / hstr (License: Apachev2) (since 2018-12-07)
Bash and Zsh shell history suggest box - easily view, navigate, search and manage your command history.
Commit 4613e4ef628dfceb32ab06159d267ca756ed3bb2

Changing default behavior to clear page on exit + adding option allowing to change it.
Author: Martin Dvorak
Author date (UTC): 2017-06-11 12:32
Committer name: Martin Dvorak
Committer date (UTC): 2017-06-11 12:32
Parent(s): 96e4fe403bc5e5994e1dd934bb8c9e548865a588
Signing key:
Tree: d1f99b8c052ed443515c5f02c30fe271422c5529
File Lines added Lines deleted
man/hh.1 3 0
src/hstr.c 6 1
src/hstr_curses.c 5 3
File man/hh.1 changed (mode: 100644) (index c81cfa5..7476b35)
... ... Configuration options:
119 119 \fIblacklist\fR \fIblacklist\fR
120 120 Load list of commands to skip when processing history from ~/.hh_blacklist (built-in blacklist used otherwise). Load list of commands to skip when processing history from ~/.hh_blacklist (built-in blacklist used otherwise).
121 121
122 \fIkeepage\fR
123 Don't clear page with command selection on exit (page is cleared by default).
124
122 125 \fIbig-keys-skip\fR \fIbig-keys-skip\fR
123 126 Skip big history entries i.e. very long lines (default). Skip big history entries i.e. very long lines (default).
124 127
File src/hstr.c changed (mode: 100644) (index 6be8d85..e94e7d2)
104 104 // MVP: model is the same regardless prompt is top or bottom - view is different // MVP: model is the same regardless prompt is top or bottom - view is different
105 105 #define HH_CONFIG_PROMPT_BOTTOM "prompt-bottom" #define HH_CONFIG_PROMPT_BOTTOM "prompt-bottom"
106 106 #define HH_CONFIG_BLACKLIST "blacklist" #define HH_CONFIG_BLACKLIST "blacklist"
107 #define HH_CONFIG_KEEP_PAGE "keepage"
107 108 #define HH_CONFIG_DEBUG "debug" #define HH_CONFIG_DEBUG "debug"
108 109 #define HH_CONFIG_WARN "warning" #define HH_CONFIG_WARN "warning"
109 110 #define HH_CONFIG_BIG_KEYS_SKIP "big-keys-skip" #define HH_CONFIG_BIG_KEYS_SKIP "big-keys-skip"
 
... ... typedef struct {
271 272 bool unique; bool unique;
272 273
273 274 unsigned char theme; unsigned char theme;
275 bool keepPage; // do NOT clear page w/ selection on HH exit
274 276 int bigKeys; int bigKeys;
275 277 int debugLevel; int debugLevel;
276 278
 
... ... void hstr_get_env_configuration(Hstr *hstr)
377 379 if(strstr(hstr_config,HH_CONFIG_BLACKLIST)) { if(strstr(hstr_config,HH_CONFIG_BLACKLIST)) {
378 380 hstr->blacklist.useFile=true; hstr->blacklist.useFile=true;
379 381 } }
382 if(strstr(hstr_config,HH_CONFIG_KEEP_PAGE)) {
383 hstr->keepPage=true;
384 }
380 385
381 386 if(strstr(hstr_config,HH_CONFIG_DEBUG)) { if(strstr(hstr_config,HH_CONFIG_DEBUG)) {
382 387 hstr->debugLevel=HH_DEBUG_LEVEL_DEBUG; hstr->debugLevel=HH_DEBUG_LEVEL_DEBUG;
 
... ... void loop_to_select(Hstr *hstr)
1330 1335 break; break;
1331 1336 } }
1332 1337 } }
1333 hstr_curses_stop();
1338 hstr_curses_stop(hstr->keepPage);
1334 1339
1335 1340 if(result!=NULL) { if(result!=NULL) {
1336 1341 if(fixCommand) { if(fixCommand) {
File src/hstr_curses.c changed (mode: 100644) (index 9c28b86..f266c73)
... ... void hstr_curses_start()
26 26 initscr(); initscr();
27 27 keypad(stdscr, TRUE); keypad(stdscr, TRUE);
28 28 noecho(); noecho();
29 nonl();
29 nonl(); // prevent carriage return from being mapped to newline
30 30 terminalHasColors=has_colors(); terminalHasColors=has_colors();
31 31 if(terminalHasColors) { if(terminalHasColors) {
32 32 start_color(); start_color();
 
... ... bool terminal_has_colors() {
38 38 return terminalHasColors; return terminalHasColors;
39 39 } }
40 40
41 void hstr_curses_stop() {
42 // removed to leave content in case of alternative page - clear();
41 void hstr_curses_stop(bool keepPage) {
42 if(!keepPage) {
43 clear();
44 }
43 45 refresh(); refresh();
44 46 doupdate(); doupdate();
45 47 endwin(); endwin();
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/hstr

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/hstr

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master