Adding non-interactive shell detection.

This commit is contained in:
Martin Dvorak 2014-01-31 21:35:16 +01:00
parent 98ede074db
commit 25988d02ea
3 changed files with 13 additions and 6 deletions

View file

@ -76,7 +76,7 @@ CONFIGURATION EXPLANATION
hh --show-configuration >> ~/.bashrc
```
* bind `hh` to a BASH key e.g. to `Ctrl-R`:
* bind `hh` to a BASH key e.g. to `Ctrl-r`:
```bash
bind '"\C-r": "\C-ahh \C-j"'
```
@ -84,6 +84,11 @@ or `Ctrl-F12`:
```bash
bind '"\e[24;5~":"\C-ahh \C-j"'
```
bind `hh` to `Ctrl-r` only if this is interactive shell:
```bash
if [[ $- =~ .*i.* ]]; then bind '"\C-r": "\C-a hh \C-j"'; fi
```
To determine the character sequence emitted by a pressed key in terminal,
type `Ctrl-v` and then press the key. Check your current bindings using:
```bash
@ -94,15 +99,15 @@ bind -S
```bash
export HH_CONFIG=hicolor
```
Show normal history by default (instead of metrics-based view):
show normal history by default (instead of metrics-based view):
```bash
export HH_CONFIG=rawhistory
```
Make search case sensitive (insensitive by default):
make search case sensitive (insensitive by default):
```bash
export HH_CONFIG=casesensitive
```
More colors and case sensitive search:
more colors and case sensitive search:
```bash
export HH_CONFIG=hicolor,casesensitive
```

View file

@ -83,7 +83,8 @@ 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 hh to Ctrl-r
# if this is interactive shell, then bind hh to Ctrl-r
if [[ $\- =~ .*i.* ]]; then bind '"\eC\-r": "\eC\-a hh \eC-j"'; fi
.sp
.fi
The prompt command ensures synchronization of the history between BASH memory

View file

@ -85,7 +85,8 @@ static const char *INSTALL_STRING=
"\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# if this is interactive shell, then bind hh to Ctrl-r"
"\nif [[ $- =~ .*i.* ]]; then bind '\"\\C-r\": \"\\C-a hh \\C-j\"'; fi"
"\n\n";
static const char *HELP_STRING=