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 19e68983fa69a9a8b52ac4b24d1d8be95c4bd985

Adding help.
Author: Martin Dvorak
Author date (UTC): 2014-01-25 13:55
Committer name: Martin Dvorak
Committer date (UTC): 2014-01-25 13:55
Parent(s): 7325a93a9f9045760dd611d672c1d81942c300a9
Signing key:
Tree: 003ecee4e70c80fd4cd9766091fb0b049b0e1cb0
File Lines added Lines deleted
src/hstr.c 29 20
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();
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