summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzsugabubus <zsugabubus@users.noreply.github.com>2021-11-19 01:36:28 +0000
committerGitHub <noreply@github.com>2021-11-19 10:36:28 +0900
commit205f885d6941eac47004779d9125df1463458fdd (patch)
tree66e082e3691b48327570c571cb74281207dd421f
parent3715cd349dfc791e96b8e12ba31a00809fdb048d (diff)
[shell] Use cd -- (#2659)
Otherwise directories starting with '-' may treated as options.
-rw-r--r--shell/key-bindings.bash2
-rw-r--r--shell/key-bindings.fish2
-rw-r--r--shell/key-bindings.zsh2
3 files changed, 3 insertions, 3 deletions
diff --git a/shell/key-bindings.bash b/shell/key-bindings.bash
index 3ea8e765..e10117e3 100644
--- a/shell/key-bindings.bash
+++ b/shell/key-bindings.bash
@@ -41,7 +41,7 @@ __fzf_cd__() {
local cmd dir
cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -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 --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m) && printf 'cd %q' "$dir"
+ dir=$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m) && printf 'cd -- %q' "$dir"
}
__fzf_history__() {
diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish
index 6f73903d..370ef1b6 100644
--- a/shell/key-bindings.fish
+++ b/shell/key-bindings.fish
@@ -87,7 +87,7 @@ function fzf_key_bindings
eval "$FZF_ALT_C_COMMAND | "(__fzfcmd)' +m --query "'$fzf_query'"' | read -l result
if [ -n "$result" ]
- cd $result
+ cd -- $result
# Remove last token from commandline.
commandline -t ""
diff --git a/shell/key-bindings.zsh b/shell/key-bindings.zsh
index 8efa6af9..72d66f57 100644
--- a/shell/key-bindings.zsh
+++ b/shell/key-bindings.zsh
@@ -79,7 +79,7 @@ fzf-cd-widget() {
return 0
fi
zle push-line # Clear buffer. Auto-restored on next prompt.
- BUFFER="cd ${(q)dir}"
+ BUFFER="cd -- ${(q)dir}"
zle accept-line
local ret=$?
unset dir # ensure this doesn't end up appearing in prompt expansion