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 c866cc140bc9936d91f51e7596b7333e9853a876

Substring search made default + MD..
Author: Martin Dvorak
Author date (UTC): 2014-04-27 12:53
Committer name: Martin Dvorak
Committer date (UTC): 2014-04-27 12:53
Parent(s): 3d625902475fbcdff89b86c75d793286009ddb3c
Signing key:
Tree: e823c56bbf103ed49843134505bb3d4a08c6fe6f
File Lines added Lines deleted
man/hh.1 6 3
src/hstr.c 11 6
File man/hh.1 changed (mode: 100644) (index 5ea49f7..03da908)
... ... Show version information
32 32 Type to filter shell history. Type to filter shell history.
33 33 .TP .TP
34 34 \fBCtrl\-e\fR \fBCtrl\-e\fR
35 Toggle regular expression and exact search.
35 Toggle regular expression and substring search.
36 36 .TP .TP
37 37 \fBCtrl\-t\fR \fBCtrl\-t\fR
38 38 Toggle case sensitive search. Toggle case sensitive search.
 
... ... Configuration options:
79 79 Get more colors with this option (default is monochromatic). Get more colors with this option (default is monochromatic).
80 80
81 81 \fIregexp\fR \fIregexp\fR
82 Search command history using regular expressions (exact match is default)
82 Filter command history using regular expressions (substring match is default)
83
84 \fIsubstring\fR
85 Filter command history using substring.
83 86
84 87 \fIcasesensitive\fR \fIcasesensitive\fR
85 Make the pattern-based filtering case sensitive (it's case insensitive by default).
88 Make history filtering case sensitive (it's case insensitive by default).
86 89
87 90 \fIrawhistory\fR \fIrawhistory\fR
88 91 Show normal history as a default view (metric-based view is shown otherwise). Show normal history as a default view (metric-based view is shown otherwise).
File src/hstr.c changed (mode: 100644) (index 275ee52..9ba350b)
70 70 #define HH_CONFIG_HICOLOR "hicolor" #define HH_CONFIG_HICOLOR "hicolor"
71 71 #define HH_CONFIG_CASE "casesensitive" #define HH_CONFIG_CASE "casesensitive"
72 72 #define HH_CONFIG_REGEXP "regexp" #define HH_CONFIG_REGEXP "regexp"
73 #define HH_CONFIG_SUBSTRING "substring"
73 74 #define HH_CONFIG_SORTING "rawhistory" #define HH_CONFIG_SORTING "rawhistory"
74 75 #define HH_CONFIG_FAVORITES "favorites" #define HH_CONFIG_FAVORITES "favorites"
75 76 #define HH_CONFIG_DEBUG "debug" #define HH_CONFIG_DEBUG "debug"
 
83 84 #define HH_VIEW_HISTORY 1 #define HH_VIEW_HISTORY 1
84 85 #define HH_VIEW_FAVORITES 2 #define HH_VIEW_FAVORITES 2
85 86
86 #define HH_MATCH_EXACT 0
87 #define HH_MATCH_REGEXP 1
87 #define HH_MATCH_SUBSTRING 0
88 #define HH_MATCH_REGEXP 1
88 89
89 90 #define HH_CASE_INSENSITIVE 0 #define HH_CASE_INSENSITIVE 0
90 91 #define HH_CASE_SENSITIVE 1 #define HH_CASE_SENSITIVE 1
 
... ... void hstr_init(Hstr *hstr)
181 182 hstr->selectionRegexpMatch=NULL; hstr->selectionRegexpMatch=NULL;
182 183 hstr->selectionSize=0; hstr->selectionSize=0;
183 184
184 hstr->historyMatch=HH_MATCH_EXACT;
185 hstr->historyMatch=HH_MATCH_SUBSTRING;
185 186 hstr->historyView=HH_VIEW_RANKING; hstr->historyView=HH_VIEW_RANKING;
186 187 hstr->caseSensitive=HH_CASE_INSENSITIVE; hstr->caseSensitive=HH_CASE_INSENSITIVE;
187 188
 
... ... void hstr_get_env_configuration(Hstr *hstr)
206 207 } }
207 208 if(strstr(hstr_config,HH_CONFIG_REGEXP)) { if(strstr(hstr_config,HH_CONFIG_REGEXP)) {
208 209 hstr->historyMatch=HH_MATCH_REGEXP; hstr->historyMatch=HH_MATCH_REGEXP;
210 } else {
211 if(strstr(hstr_config,HH_CONFIG_SUBSTRING)) {
212 hstr->historyMatch=HH_MATCH_SUBSTRING;
213 }
209 214 } }
210 215 if(strstr(hstr_config,HH_CONFIG_SORTING)) { if(strstr(hstr_config,HH_CONFIG_SORTING)) {
211 216 hstr->historyView=HH_VIEW_HISTORY; hstr->historyView=HH_VIEW_HISTORY;
 
... ... unsigned hstr_make_selection(char *prefix, HistoryItems *history, int maxSelecti
386 391 hstr->selection[selectionCount++]=source[i]; hstr->selection[selectionCount++]=source[i];
387 392 } else { } else {
388 393 switch(hstr->historyMatch) { switch(hstr->historyMatch) {
389 case HH_MATCH_EXACT:
394 case HH_MATCH_SUBSTRING:
390 395 switch(hstr->caseSensitive) { switch(hstr->caseSensitive) {
391 396 case HH_CASE_SENSITIVE: case HH_CASE_SENSITIVE:
392 397 if(source[i]==strstr(source[i], prefix)) { if(source[i]==strstr(source[i], prefix)) {
 
... ... unsigned hstr_make_selection(char *prefix, HistoryItems *history, int maxSelecti
417 422 char *substring; char *substring;
418 423 for(i=0; i<count && selectionCount<maxSelectionCount; i++) { for(i=0; i<count && selectionCount<maxSelectionCount; i++) {
419 424 switch(hstr->historyMatch) { switch(hstr->historyMatch) {
420 case HH_MATCH_EXACT:
425 case HH_MATCH_SUBSTRING:
421 426 switch(hstr->caseSensitive) { switch(hstr->caseSensitive) {
422 427 case HH_CASE_SENSITIVE: case HH_CASE_SENSITIVE:
423 428 substring = strstr(source[i], prefix); substring = strstr(source[i], prefix);
 
... ... void print_selection_row(char *text, int y, int width, char *pattern)
455 460 char *p; char *p;
456 461
457 462 switch(hstr->historyMatch) { switch(hstr->historyMatch) {
458 case HH_MATCH_EXACT:
463 case HH_MATCH_SUBSTRING:
459 464 switch(hstr->caseSensitive) { switch(hstr->caseSensitive) {
460 465 case HH_CASE_INSENSITIVE: case HH_CASE_INSENSITIVE:
461 466 p=strcasestr(text, pattern); p=strcasestr(text, pattern);
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