diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2015-07-13 00:22:13 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-07-13 00:22:13 +0900 |
commit | 392da53f5380907fdc7c21f398612be82f7dc3e0 (patch) | |
tree | 91f6d0e22a27bd100b437e6316680ca41c9191e3 /shell | |
parent | ae72b0fb70481f4b6d94b1ab139e1795a9d9d2ca (diff) |
[bash] Make CTRL-R work when histexpand is unset (#286)
Note that it still can't handle properly multi-line commands.
Thanks to @jpcirrus for the bug report and the fix.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/key-bindings.bash | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/shell/key-bindings.bash b/shell/key-bindings.bash index c04dc440..0bfd50d6 100644 --- a/shell/key-bindings.bash +++ b/shell/key-bindings.bash @@ -34,13 +34,19 @@ __fzf_cd__() { -o -type d -print 2> /dev/null | sed 1d | cut -b3- | $(__fzfcmd) +m) && printf 'cd %q' "$dir" } -__fzf_history__() { +__fzf_history__() ( local line + shopt -u nocaseglob nocasematch line=$( HISTTIMEFORMAT= history | $(__fzfcmd) +s --tac +m -n2..,.. --tiebreak=index --toggle-sort=ctrl-r | - \grep '^ *[0-9]') && sed 's/ *\([0-9]*\)\** .*/!\1/' <<< "$line" -} + \grep '^ *[0-9]') && + if [[ $- =~ H ]]; then + sed 's/^ *\([0-9]*\)\** .*/!\1/' <<< "$line" + else + sed 's/^ *\([0-9]*\)\** *//' <<< "$line" + fi +) __use_tmux=0 [ -n "$TMUX_PANE" -a ${FZF_TMUX:-1} -ne 0 -a ${LINES:-40} -gt 15 ] && __use_tmux=1 |