diff options
author | Oliver Kiddle <opk@zsh.org> | 2015-06-21 00:44:27 +0200 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2015-06-21 09:21:35 +0200 |
commit | d395ebd28f3be44e4fd6edfc38c919b80879bc15 (patch) | |
tree | 9d7e99127edaa82c6d32cd0c6a47a17b82e13098 | |
parent | c0d3faa84f24baa55fbb874080fc49f534941702 (diff) |
use vi-fetch-history on zsh to get history line
In addition to being simpler, it allows subsequent up/down history
or accept-line-and-down-history widgets to work.
Also allow for find being and alias if alias expansion
after command is enabled.
-rw-r--r-- | shell/key-bindings.zsh | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/shell/key-bindings.zsh b/shell/key-bindings.zsh index 86630d00..fecef20e 100644 --- a/shell/key-bindings.zsh +++ b/shell/key-bindings.zsh @@ -26,7 +26,7 @@ bindkey '^T' fzf-file-widget # ALT-C - cd into the selected directory fzf-cd-widget() { - cd "${$(command find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \ + cd "${$(command \find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \ -o -type d -print 2> /dev/null | sed 1d | cut -b3- | $(__fzfcmd) +m):-.}" zle reset-prompt } @@ -36,16 +36,10 @@ bindkey '\ec' fzf-cd-widget # CTRL-R - Paste the selected command from history into the command line fzf-history-widget() { local selected restore_no_bang_hist - if selected=$(fc -l 1 | $(__fzfcmd) +s --tac +m -n2..,.. --tiebreak=index --toggle-sort=ctrl-r -q "$LBUFFER"); then - num=$(echo "$selected" | head -n1 | awk '{print $1}' | sed 's/[^0-9]//g') + if selected=( $(fc -l 1 | $(__fzfcmd) +s --tac +m -n2..,.. --tiebreak=index --toggle-sort=ctrl-r -q "$LBUFFER") ); then + num=$selected[1] if [ -n "$num" ]; then - LBUFFER=!$num - if setopt | grep nobanghist > /dev/null; then - restore_no_bang_hist=1 - unsetopt no_bang_hist - fi - zle expand-history - [ -n "$restore_no_bang_hist" ] && setopt no_bang_hist + zle vi-fetch-history -n $num fi fi zle redisplay |