[shell] Replace `sed` with `-mindepth 1` and `cut` (#844)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Pierre Neidhardt · committed by Junegunn Choi · parent 21da02f · Browse files · 3 files·+8 added−9 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+8 added−9 removed
- other:+8 added−9 removed
Provenance
- Commit
ce43ea9- Tree
46403e6- Author
Pierre Neidhardt <ambrevar@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
21da02f
3 files changed+8 added−9 removed
modified:shell/key-bindings.bash+2 added-2 removed
44 unmodified lines45464748495049505152535467 unmodified lines44 unmodified lines}
__fzf_cd__() { local cmd dir cmd="${FZF_ALT_C_COMMAND:-"command find -L . \\( -path '*/\\.*' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ -o -type d -print 2> /dev/null | sed 1d | cut -b3-"}" cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ -o -type d -print 2> /dev/null | cut -b3-"}" dir=$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m) && printf 'cd %q' "$dir"}
__fzf_history__() (67 unmodified linesmodified:shell/key-bindings.fish+4 added-4 removed
1 # Key bindings2 # ------------3 function fzf_key_bindings4 5- # Store last token in $dir as root for the 'find' command5+ # Store current token in $dir as root for the 'find' command6 function fzf-file-widget -d "List files and folders"7 set -l dir (commandline -t)8 # The commandline token might be escaped, we need to unescape it.9 set dir (eval "printf '%s' $dir")8 unmodified lines18 set -q FZF_CTRL_T_COMMAND; or set -l FZF_CTRL_T_COMMAND "19 command find -L \$dir -mindepth 1 \\( -path \$dir'*/\\.*' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \20 -o -type f -print \21 -o -type d -print \22- -o -type l -print 2> /dev/null | sed 's#^\./##'"22+ -o -type l -print 2> /dev/null | cut -b3-"23 24 set -q FZF_TMUX_HEIGHT; or set FZF_TMUX_HEIGHT 40%25 begin26 set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS"26 unmodified lines53 end54 55 function fzf-cd-widget -d "Change directory"56 set -q FZF_ALT_C_COMMAND; or set -l FZF_ALT_C_COMMAND "57- command find -L . \\( -path '*/\\.*' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \58- -o -type d -print 2> /dev/null | sed 1d | cut -b3-"57+ command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \58+ -o -type d -print 2> /dev/null | cut -b3-"59 set -q FZF_TMUX_HEIGHT; or set FZF_TMUX_HEIGHT 40%60 begin61 set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS"62 eval "$FZF_ALT_C_COMMAND | "(__fzfcmd)" +m" | read -l result25 unmodified linesmodified:shell/key-bindings.zsh+2 added-3 removed
36 unmodified lines37 bindkey '^T' fzf-file-widget38 39 # ALT-C - cd into the selected directory40 fzf-cd-widget() {41- local cmd="${FZF_ALT_C_COMMAND:-"command find -L . \\( -path '*/\\.*' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \42- -o -type d -print 2> /dev/null | sed 1d | cut -b3-"}"41+ local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \42+ -o -type d -print 2> /dev/null | cut -b3-"}"43 setopt localoptions pipefail 2> /dev/null44 local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)"45 if [[ -z "$dir" ]]; then46 zle redisplay28 unmodified lines75 zle -N fzf-history-widget76 bindkey '^R' fzf-history-widget77 78 fi79-