summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorPierre Neidhardt <ambrevar@gmail.com>2017-02-16 09:18:01 +0100
committerJunegunn Choi <junegunn.c@gmail.com>2017-02-16 17:18:01 +0900
commitce43ea9f4273ef2b4c67cb02dc55ed883f6c0fd9 (patch)
tree46403e619d0f53cd5f10bc255ae75612f9e32f61 /shell
parent21da02fac2a6f8fd04052165efa52f8c11399bb7 (diff)
[shell] Replace `sed` with `-mindepth 1` and `cut` (#844)
Diffstat (limited to 'shell')
-rw-r--r--shell/key-bindings.bash4
-rw-r--r--shell/key-bindings.fish8
-rw-r--r--shell/key-bindings.zsh5
3 files changed, 8 insertions, 9 deletions
diff --git a/shell/key-bindings.bash b/shell/key-bindings.bash
index 69dd0ce4..b1505334 100644
--- a/shell/key-bindings.bash
+++ b/shell/key-bindings.bash
@@ -46,8 +46,8 @@ fzf-file-widget() {
__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"
}
diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish
index ce2d4e01..6b239ba0 100644
--- a/shell/key-bindings.fish
+++ b/shell/key-bindings.fish
@@ -2,7 +2,7 @@
# ------------
function fzf_key_bindings
- # Store last token in $dir as root for the 'find' command
+ # Store current token in $dir as root for the 'find' command
function fzf-file-widget -d "List files and folders"
set -l dir (commandline -t)
# The commandline token might be escaped, we need to unescape it.
@@ -19,7 +19,7 @@ function fzf_key_bindings
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 's#^\./##'"
+ -o -type l -print 2> /dev/null | cut -b3-"
set -q FZF_TMUX_HEIGHT; or set FZF_TMUX_HEIGHT 40%
begin
@@ -54,8 +54,8 @@ function fzf_key_bindings
function fzf-cd-widget -d "Change directory"
set -q FZF_ALT_C_COMMAND; or set -l FZF_ALT_C_COMMAND "
- command find -L . \\( -path '*/\\.*' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \
- -o -type d -print 2> /dev/null | sed 1d | cut -b3-"
+ command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \
+ -o -type d -print 2> /dev/null | cut -b3-"
set -q FZF_TMUX_HEIGHT; or set FZF_TMUX_HEIGHT 40%
begin
set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS"
diff --git a/shell/key-bindings.zsh b/shell/key-bindings.zsh
index 6ac38d2c..a04e1d84 100644
--- a/shell/key-bindings.zsh
+++ b/shell/key-bindings.zsh
@@ -38,8 +38,8 @@ bindkey '^T' fzf-file-widget
# ALT-C - cd into the selected directory
fzf-cd-widget() {
- local 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-"}"
+ local 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-"}"
setopt localoptions pipefail 2> /dev/null
local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)"
if [[ -z "$dir" ]]; then
@@ -76,4 +76,3 @@ zle -N fzf-history-widget
bindkey '^R' fzf-history-widget
fi
-