2
0
mirror of https://github.com/junegunn/fzf synced 2024-10-30 09:20:14 +00:00

[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.
This commit is contained in:
Junegunn Choi 2015-07-13 00:22:13 +09:00
parent ae72b0fb70
commit 392da53f53

View File

@ -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