diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2015-01-25 11:20:20 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-01-25 11:20:20 +0900 |
commit | 47201c2c4dc7d5e178212e0209f5db1fa5949631 (patch) | |
tree | 74e0ba77cb543a77a59eceb41e77a04e9280c73f | |
parent | 9cb0cdb4aca2d0d71b619e1707cda9d69e224790 (diff) | |
parent | 53d5d9d1624d23175eca4c1e1bd93bbbb7b41b0c (diff) |
Merge pull request #122 from blueyed/improve-find-cdwidget
Improve `find` command for ALT-C: exclude proc/dev
-rwxr-xr-x | install | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -202,10 +202,10 @@ EOF # Key bindings # ------------ __fsel() { - command find * -path '*/\.*' -prune \ + 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 | fzf -m | while read item; do + -o -type l -print 2> /dev/null | sed 1d | cut -b3- | fzf -m | while read item; do printf '%q ' "$item" done echo @@ -226,7 +226,8 @@ __fsel_tmux() { __fcd() { local dir - dir=$(command find -L ${1:-*} -path '*/\.*' -prune -o -type d -print 2> /dev/null | fzf +m) && printf 'cd %q' "$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- | fzf +m) && printf 'cd %q' "$dir" } __use_tmux=0 @@ -274,17 +275,16 @@ unset __use_tmux fi EOFZF - else + else # zsh cat >> $src << "EOFZF" # Key bindings # ------------ # CTRL-T - Paste the selected file path(s) into the command line __fsel() { - set -o nonomatch - command find * -path '*/\.*' -prune \ + 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 | fzf -m | while read item; do + -o -type l -print 2> /dev/null | sed 1d | cut -b3- | fzf -m | while read item; do printf '%q ' "$item" done echo @@ -314,8 +314,8 @@ bindkey '^T' fzf-file-widget # ALT-C - cd into the selected directory fzf-cd-widget() { - cd "${$(set -o nonomatch; command find -L * -path '*/\.*' -prune \ - -o -type d -print 2> /dev/null | fzf):-.}" + cd "${$(command find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \ + -o -type d -print 2> /dev/null | sed 1d | cut -b3- | fzf +m):-.}" zle reset-prompt } zle -N fzf-cd-widget @@ -369,14 +369,15 @@ function fzf_key_bindings end function __fzf_list - command find * -path '*/\.*' -prune \ + 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 + -o -type l -print 2> /dev/null | sed 1d | cut -b3- end function __fzf_list_dir - command find -L * -path '*/\.*' -prune -o -type d -print 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- end function __fzf_escape |