mirror of
https://github.com/dvorka/hstr.git
synced 2024-12-28 18:50:54 +08:00
Improved configuration and man - fixed #45.
This commit is contained in:
parent
fa65c1fd31
commit
7325a93a9f
2 changed files with 27 additions and 16 deletions
21
man/hh.1
21
man/hh.1
|
@ -11,7 +11,7 @@ file that is filtered as you type a command substring. Commands
|
|||
are not just filtered, but also ordered by a ranking algorithm
|
||||
that considers number of occurences, length and timestamp. In addition
|
||||
hh allows removal of commands from history - for instance with a typo or with a sensitive content.
|
||||
.SH OPTIONNS
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB--show-configuration\fR
|
||||
Show configuration to be added to .bashrc
|
||||
|
@ -41,6 +41,12 @@ Choose currently selected item for completion and execute it.
|
|||
\fBDEL\fR
|
||||
Remove currently selected item from the shell history.
|
||||
.TP
|
||||
\fBBACSKSPACE\fR, \fBCtrl\-h\fR
|
||||
Delete last pattern character.
|
||||
.TP
|
||||
\fBCtrl\-u\fR, \fBCtrl\-w\fR
|
||||
Delete pattern and search again.
|
||||
.TP
|
||||
\fBCtrl\-x\fR
|
||||
Write changes to shell history and exit.
|
||||
.TP
|
||||
|
@ -50,15 +56,16 @@ Exit with empty prompt.
|
|||
Add the following lines to ~/.bashrc:
|
||||
.nf
|
||||
.sp
|
||||
shopt -s histappend
|
||||
shopt -s histappend # append new history items to .bash_history
|
||||
export HISTCONTROL=ignorespace # leading space hides commands from history
|
||||
export HISTFILESIZE=10000 # increase history file size (default is 500)
|
||||
export HISTSIZE=${HISTFILESIZE} # increase history size (default is 500)
|
||||
export PROMPT_COMMAND="history \-a; history \-n; ${PROMPT_COMMAND}"
|
||||
bind '"\eC\-r": "\eC\-a hh \eC-j"'
|
||||
bind '"\eC\-r": "\eC\-a hh \eC-j"' # bind hh to Ctrl-r
|
||||
.sp
|
||||
.fi
|
||||
The first command ensures that new history items are appended to .bash_history
|
||||
(instead of overwriting). The second command ensures synchronization of the
|
||||
history between memory and file system. The third command binds hh to
|
||||
Ctrl-r shortcut.
|
||||
The prompt command ensures synchronization of the history between BASH memory
|
||||
and history file.
|
||||
.SH AUTHOR
|
||||
Written by Martin Dvorak <martin.dvorak@mindforger.com>
|
||||
.SH BUGS
|
||||
|
|
22
src/hstr.c
22
src/hstr.c
|
@ -66,10 +66,13 @@
|
|||
#endif
|
||||
|
||||
static const char *INSTALL_STRING=
|
||||
"\n# Add this configuration to ~/.bashrc to let HH load and flush up to date history"
|
||||
"\nshopt -s histappend"
|
||||
"\nexport PROMPT_COMMAND=\"history -a; history -n; ${PROMPT_COMMAND}\""
|
||||
"\nbind '\"\\C-r\": \"\\C-a hh \\C-j\"'"
|
||||
"\n# add this configuration to ~/.bashrc"
|
||||
"\nshopt -s histappend # append new history items to .bash_history"
|
||||
"\nexport HISTCONTROL=ignorespace # leading space hides commands from history"
|
||||
"\nexport HISTFILESIZE=10000 # increase history file size (default is 500)"
|
||||
"\nexport HISTSIZE=${HISTFILESIZE} # increase history size (default is 500)"
|
||||
"\nexport PROMPT_COMMAND=\"history -a; history -n; ${PROMPT_COMMAND}\" # mem/file sync"
|
||||
"\nbind '\"\\C-r\": \"\\C-a hh \\C-j\"' # bind hh to Ctrl-r"
|
||||
"\n\n";
|
||||
|
||||
static const char *BUILD_STRING=
|
||||
|
@ -383,10 +386,6 @@ void loop_to_select(HistoryItems *history)
|
|||
print_history_label(history);
|
||||
selectionCursorPosition=0;
|
||||
break;
|
||||
case K_CTRL_X:
|
||||
result=NULL;
|
||||
done=TRUE;
|
||||
break;
|
||||
case KEY_RESIZE:
|
||||
print_history_label(history);
|
||||
move(y, basex+strlen(pattern));
|
||||
|
@ -462,6 +461,10 @@ void loop_to_select(HistoryItems *history)
|
|||
history_clear_dirty();
|
||||
done=TRUE;
|
||||
break;
|
||||
case K_CTRL_X:
|
||||
result=NULL;
|
||||
done=TRUE;
|
||||
break;
|
||||
default:
|
||||
LOGKEYS(Y_OFFSET_HELP, c);
|
||||
LOGCURSOR(Y_OFFSET_HELP);
|
||||
|
@ -495,7 +498,7 @@ void loop_to_select(HistoryItems *history)
|
|||
|
||||
void install_show()
|
||||
{
|
||||
printf("# %s\n%s", BUILD_STRING, INSTALL_STRING);
|
||||
printf("%s", INSTALL_STRING);
|
||||
}
|
||||
|
||||
void assemble_cmdline(int argc, char *argv[]) {
|
||||
|
@ -535,6 +538,7 @@ int main(int argc, char *argv[])
|
|||
if(argc==2 && strstr(argv[1], "--show-configuration")) {
|
||||
install_show();
|
||||
// TODO --help (tr --help)
|
||||
//printf("# %s\n%s", BUILD_STRING, INSTALL_STRING);
|
||||
} else {
|
||||
assemble_cmdline(argc, argv);
|
||||
hstr();
|
||||
|
|
Loading…
Reference in a new issue