From c7b076400297e53b3fdb9bb0605b0c688a39fa40 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Sat, 24 Dec 2016 09:23:07 +0530 Subject: [shell] Use '-mindepth 1' to omit root folder in 'find' output (#779) This removes the need for the 'sed' call. Faster, cleaner. --- shell/key-bindings.bash | 4 ++-- shell/key-bindings.fish | 4 ++-- shell/key-bindings.zsh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'shell') diff --git a/shell/key-bindings.bash b/shell/key-bindings.bash index d41eb5bd..8c3e6f77 100644 --- a/shell/key-bindings.bash +++ b/shell/key-bindings.bash @@ -1,10 +1,10 @@ # Key bindings # ------------ __fzf_select__() { - local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . \\( -path '*/\\.*' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ + local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ -o -type f -print \ -o -type d -print \ - -o -type l -print 2> /dev/null | sed 1d | cut -b3-"}" + -o -type l -print 2> /dev/null | cut -b3-"}" eval "$cmd | fzf -m $FZF_CTRL_T_OPTS" | while read -r item; do printf '%q ' "$item" done diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish index b520d8b8..dd75fecf 100644 --- a/shell/key-bindings.fish +++ b/shell/key-bindings.fish @@ -16,10 +16,10 @@ function fzf_key_bindings # "-path \$dir'*/\\.*'" matches hidden files/folders inside $dir but not # $dir itself, even if hidden. set -q FZF_CTRL_T_COMMAND; or set -l FZF_CTRL_T_COMMAND " - command find -L \$dir \\( -path \$dir'*/\\.*' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \ + command find -L \$dir -mindepth 1 \\( -path \$dir'*/\\.*' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \ -o -type f -print \ -o -type d -print \ - -o -type l -print 2> /dev/null | sed '1d; s#^\./##'" + -o -type l -print 2> /dev/null | sed 's#^\./##'" eval "$FZF_CTRL_T_COMMAND | "(__fzfcmd)" -m $FZF_CTRL_T_OPTS" | while read -l r; set result $result $r; end if [ -z "$result" ] diff --git a/shell/key-bindings.zsh b/shell/key-bindings.zsh index fc694cb6..fed01532 100644 --- a/shell/key-bindings.zsh +++ b/shell/key-bindings.zsh @@ -4,10 +4,10 @@ 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 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ + local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ -o -type f -print \ -o -type d -print \ - -o -type l -print 2> /dev/null | sed 1d | cut -b3-"}" + -o -type l -print 2> /dev/null | cut -b3-"}" setopt localoptions pipefail 2> /dev/null eval "$cmd | $(__fzfcmd) -m $FZF_CTRL_T_OPTS" | while read item; do echo -n "${(q)item} " -- cgit v1.2.3