diff options
author | ptzz <ponca707@gmail.com> | 2018-06-02 03:40:33 +0200 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2018-06-02 10:40:33 +0900 |
commit | 2b19c0bc685fc2f726b977d161e6ce720a4d04a8 (patch) | |
tree | 8a7bad332c6e651d1bd489fb9cb52d165d375ed1 | |
parent | 76a2dcb5a95c3027eeb811c0abb9331928c13653 (diff) |
[bash/zsh] Fix missing fuzzy completions (#1303)
* [bash/zsh] Fix missing fuzzy completions
`cat foo**<TAB>` did not display the file `foobar` if there was a directory
named `foo`.
Fixes #1301
* [zsh] Evaluate completion prefix
cat $HOME**
cat ~username**
cat ~username/foo**
-rw-r--r-- | shell/completion.bash | 2 | ||||
-rw-r--r-- | shell/completion.zsh | 9 |
2 files changed, 5 insertions, 6 deletions
diff --git a/shell/completion.bash b/shell/completion.bash index b3d28f28..86b78526 100644 --- a/shell/completion.bash +++ b/shell/completion.bash @@ -148,7 +148,7 @@ __fzf_generic_path_completion() { base=${cur:0:${#cur}-${#trigger}} eval "base=$base" - dir="$base" + [[ $base = *"/"* ]] && dir="$base" while true; do if [ -z "$dir" ] || [ -d "$dir" ]; then leftover=${base/#"$dir"} diff --git a/shell/completion.zsh b/shell/completion.zsh index 2e25c582..1e3ced8e 100644 --- a/shell/completion.zsh +++ b/shell/completion.zsh @@ -36,8 +36,7 @@ __fzfcmd_complete() { __fzf_generic_path_completion() { local base lbuf compgen fzf_opts suffix tail fzf dir leftover matches - # (Q) flag removes a quoting level: "foo\ bar" => "foo bar" - base=${(Q)1} + base=$1 lbuf=$2 compgen=$3 fzf_opts=$4 @@ -46,14 +45,14 @@ __fzf_generic_path_completion() { fzf="$(__fzfcmd_complete)" setopt localoptions nonomatch - dir="$base" + eval "base=$base" + [[ $base = *"/"* ]] && dir="$base" while [ 1 ]; do - if [[ -z "$dir" || -d ${~dir} ]]; then + if [[ -z "$dir" || -d ${dir} ]]; then leftover=${base/#"$dir"} leftover=${leftover/#\/} [ -z "$dir" ] && dir='.' [ "$dir" != "/" ] && dir="${dir/%\//}" - dir=${~dir} matches=$(eval "$compgen $(printf %q "$dir")" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS" ${=fzf} ${=fzf_opts} -q "$leftover" | while read item; do echo -n "${(q)item}$suffix " done) |