File src/hstr.c changed (mode: 100644) (index a1434ca..9901049) |
66 |
66 |
#endif |
#endif |
67 |
67 |
|
|
68 |
68 |
static const char *INSTALL_STRING= |
static const char *INSTALL_STRING= |
69 |
|
"\n# add this configuration to ~/.bashrc" |
|
70 |
|
"\nshopt -s histappend # append new history items to .bash_history" |
|
71 |
|
"\nexport HISTCONTROL=ignorespace # leading space hides commands from history" |
|
72 |
|
"\nexport HISTFILESIZE=10000 # increase history file size (default is 500)" |
|
73 |
|
"\nexport HISTSIZE=${HISTFILESIZE} # increase history size (default is 500)" |
|
74 |
|
"\nexport PROMPT_COMMAND=\"history -a; history -n; ${PROMPT_COMMAND}\" # mem/file sync" |
|
75 |
|
"\nbind '\"\\C-r\": \"\\C-a hh \\C-j\"' # bind hh to Ctrl-r" |
|
76 |
|
"\n\n"; |
|
77 |
|
|
|
78 |
|
static const char *BUILD_STRING= |
|
79 |
|
"HH build: "__DATE__" " __TIME__""; |
|
|
69 |
|
"\n# add this configuration to ~/.bashrc" |
|
70 |
|
"\nshopt -s histappend # append new history items to .bash_history" |
|
71 |
|
"\nexport HISTCONTROL=ignorespace # leading space hides commands from history" |
|
72 |
|
"\nexport HISTFILESIZE=10000 # increase history file size (default is 500)" |
|
73 |
|
"\nexport HISTSIZE=${HISTFILESIZE} # increase history size (default is 500)" |
|
74 |
|
"\nexport PROMPT_COMMAND=\"history -a; history -n; ${PROMPT_COMMAND}\" # mem/file sync" |
|
75 |
|
"\nbind '\"\\C-r\": \"\\C-a hh \\C-j\"' # bind hh to Ctrl-r" |
|
76 |
|
"\n\n"; |
|
77 |
|
|
|
78 |
|
static const char *HELP_STRING= |
|
79 |
|
"Usage: hh [option] [arg1] [arg2]..." |
|
80 |
|
"\nShell history suggest box (build: "__DATE__" " __TIME__")" |
|
81 |
|
"\n" |
|
82 |
|
"\n --show-configuration ... show configuration to be added to .bashrc" |
|
83 |
|
"\n --help ... display this help and exit" |
|
84 |
|
"\n" |
|
85 |
|
"\nReport bugs to martin.dvorak@mindforger.com" |
|
86 |
|
"\nHome page: https://github.com/dvorka/hstr" |
|
87 |
|
"\n"; |
80 |
88 |
|
|
81 |
89 |
static const char *LABEL_HELP= |
static const char *LABEL_HELP= |
82 |
90 |
"Type to filter, UP/DOWN to move, DEL to remove, TAB to select, C-g to cancel"; |
"Type to filter, UP/DOWN to move, DEL to remove, TAB to select, C-g to cancel"; |
|
... |
... |
void loop_to_select(HistoryItems *history) |
496 |
504 |
} |
} |
497 |
505 |
} |
} |
498 |
506 |
|
|
499 |
|
void install_show() |
|
500 |
|
{ |
|
501 |
|
printf("%s", INSTALL_STRING); |
|
502 |
|
} |
|
503 |
|
|
|
504 |
507 |
void assemble_cmdline(int argc, char *argv[]) { |
void assemble_cmdline(int argc, char *argv[]) { |
505 |
508 |
// TODO support BASH substitutions: !!, !!ps, !$, !* |
// TODO support BASH substitutions: !!, !!ps, !$, !* |
506 |
509 |
int i; |
int i; |
|
... |
... |
void hstr() |
535 |
538 |
int main(int argc, char *argv[]) |
int main(int argc, char *argv[]) |
536 |
539 |
{ |
{ |
537 |
540 |
if(argc>0) { |
if(argc>0) { |
538 |
|
if(argc==2 && strstr(argv[1], "--show-configuration")) { |
|
539 |
|
install_show(); |
|
540 |
|
// TODO --help (tr --help) |
|
541 |
|
//printf("# %s\n%s", BUILD_STRING, INSTALL_STRING); |
|
|
541 |
|
if(argc==2) { |
|
542 |
|
if(strstr(argv[1], "--show-configuration")) { |
|
543 |
|
printf("%s", INSTALL_STRING); |
|
544 |
|
return EXIT_SUCCESS; |
|
545 |
|
} |
|
546 |
|
if(strstr(argv[1], "--help")) { |
|
547 |
|
// TODO --help (tr --help) |
|
548 |
|
printf("%s", HELP_STRING); |
|
549 |
|
return EXIT_SUCCESS; |
|
550 |
|
} |
542 |
551 |
} else { |
} else { |
543 |
552 |
assemble_cmdline(argc, argv); |
assemble_cmdline(argc, argv); |
544 |
553 |
hstr(); |
hstr(); |