Skip to content

Commit

Permalink
fix: use _comp_compgen_split while keeping filtering by $cur
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jan 14, 2024
1 parent 158b8ba commit a00ee19
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
12 changes: 8 additions & 4 deletions completions/slapt-get
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ _comp_cmd_slapt_get()
# slapt-get will fail to search for "^name-version"
# it can search for names only
local name=${cur%%-*}
COMPREPLY=($(LC_ALL=C "$1" -c "$config" --search "^$name" \
2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p;}"))
_comp_compgen_split -l -- "$(
LC_ALL=C "$1" -c "$config" --search "^$name" 2>/dev/null |
LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p;}"
)"
return
;;
avl) # --install|-i|
COMPREPLY=($(LC_ALL=C "$1" -c "$config" --available \
2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p;}"))
_comp_compgen_split -l -- "$(
LC_ALL=C "$1" -c "$config" --available 2>/dev/null |
LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p;}"
)"
return
;;
ins) # --remove|--filelist
Expand Down
15 changes: 10 additions & 5 deletions completions/slapt-src
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,17 @@ _comp_cmd_slapt_src()

if [[ $cur == *:* ]]; then
local name=${cur%:*}
COMPREPLY=($(LC_ALL=C "$1" --config "$config" --search "^$name" \
2>/dev/null | LC_ALL=C command sed -ne \
"/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p;}"))
_comp_compgen_split -l -- "$(
LC_ALL=C
"$1" --config "$config" --search "^$name" 2>/dev/null |
command sed -ne "/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p;}"
)"
else
COMPREPLY=($(LC_ALL=C "$1" --config "$config" --search "^$cur" \
2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p;}"))
_comp_compgen_split -l -- "$(
LC_ALL=C
"$1" --config "$config" --search "^$cur" 2>/dev/null |
command sed -ne "/^$cur/{s/ .*$//;p;}"
)"
fi
} &&
complete -F _comp_cmd_slapt_src slapt-src
Expand Down

0 comments on commit a00ee19

Please sign in to comment.