diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2015-11-08 00:11:46 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-11-08 00:12:12 +0900 |
commit | e99731ea852d1faac5390594cd980708edf826cf (patch) | |
tree | 91705daf049196425808c621d4676c1111813057 /shell | |
parent | 15659ac6e6ae413d86dc8229c7827e6983bad9db (diff) |
[shell] Add FZF_ALT_C_COMMAND for ALT-C (#408)
Diffstat (limited to 'shell')
-rw-r--r-- | shell/key-bindings.bash | 9 | ||||
-rw-r--r-- | shell/key-bindings.fish | 6 | ||||
-rw-r--r-- | shell/key-bindings.zsh | 7 |
3 files changed, 13 insertions, 9 deletions
diff --git a/shell/key-bindings.bash b/shell/key-bindings.bash index 0bfd50d6..e9bea78d 100644 --- a/shell/key-bindings.bash +++ b/shell/key-bindings.bash @@ -1,7 +1,7 @@ # Key bindings # ------------ __fzf_select__() { - local cmd="${FZF_CTRL_T_COMMAND:-"command \\find -L . \\( -path '*/\\.*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \ + local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . \\( -path '*/\\.*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \ -o -type f -print \ -o -type d -print \ -o -type l -print 2> /dev/null | sed 1d | cut -b3-"}" @@ -29,9 +29,10 @@ __fzf_select_tmux__() { } __fzf_cd__() { - local dir - dir=$(command \find -L ${1:-.} \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \ - -o -type d -print 2> /dev/null | sed 1d | cut -b3- | $(__fzfcmd) +m) && printf 'cd %q' "$dir" + local cmd dir + cmd="${FZF_ALT_C_COMMAND:-"command find -L . \\( -path '*/\\.*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \ + -o -type d -print 2> /dev/null | sed 1d | cut -b3-"}" + dir=$(eval "$cmd" | $(__fzfcmd) +m) && printf 'cd %q' "$dir" } __fzf_history__() ( diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish index a08df3df..3d3c2a72 100644 --- a/shell/key-bindings.fish +++ b/shell/key-bindings.fish @@ -33,9 +33,11 @@ function fzf_key_bindings end function __fzf_alt_c + set -q FZF_ALT_C_COMMAND; or set -l FZF_ALT_C_COMMAND " + command find -L . \\( -path '*/\\.*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \ + -o -type d -print 2> /dev/null | sed 1d | cut -b3-" # Fish hangs if the command before pipe redirects (2> /dev/null) - command find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) \ - -prune -o -type d -print 2> /dev/null | sed 1d | cut -b3- | eval (__fzfcmd) +m > $TMPDIR/fzf.result + eval "$FZF_ALT_C_COMMAND | "(__fzfcmd)" +m > $TMPDIR/fzf.result" [ (cat $TMPDIR/fzf.result | wc -l) -gt 0 ] and cd (cat $TMPDIR/fzf.result) commandline -f repaint diff --git a/shell/key-bindings.zsh b/shell/key-bindings.zsh index eccc8266..29721fc9 100644 --- a/shell/key-bindings.zsh +++ b/shell/key-bindings.zsh @@ -4,7 +4,7 @@ if [[ $- == *i* ]]; then # CTRL-T - Paste the selected file path(s) into the command line __fsel() { - local cmd="${FZF_CTRL_T_COMMAND:-"command \\find -L . \\( -path '*/\\.*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \ + local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . \\( -path '*/\\.*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \ -o -type f -print \ -o -type d -print \ -o -type l -print 2> /dev/null | sed 1d | cut -b3-"}" @@ -27,8 +27,9 @@ 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 \ - -o -type d -print 2> /dev/null | sed 1d | cut -b3- | $(__fzfcmd) +m):-.}" + local cmd="${FZF_ALT_C_COMMAND:-"command find -L . \\( -path '*/\\.*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \ + -o -type d -print 2> /dev/null | sed 1d | cut -b3-"}" + cd "${$(eval "$cmd" | $(__fzfcmd) +m):-.}" zle reset-prompt } zle -N fzf-cd-widget |