summaryrefslogtreecommitdiffstats
path: root/shell/completion.zsh
diff options
context:
space:
mode:
authorptzz <ponca707@gmail.com>2018-06-02 03:40:33 +0200
committerJunegunn Choi <junegunn.c@gmail.com>2018-06-02 10:40:33 +0900
commit2b19c0bc685fc2f726b977d161e6ce720a4d04a8 (patch)
tree8a7bad332c6e651d1bd489fb9cb52d165d375ed1 /shell/completion.zsh
parent76a2dcb5a95c3027eeb811c0abb9331928c13653 (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**
Diffstat (limited to 'shell/completion.zsh')
-rw-r--r--shell/completion.zsh9
1 files changed, 4 insertions, 5 deletions
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)