Skip to content

completion: handle , in node list #575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions bash_completion.d/cluset
Original file line number Diff line number Diff line change
@@ -41,6 +41,35 @@ _cluset()
case "$prev" in
-c|--count|-e|--expand|-f|--fold|\
-x|--exclude|-i|--intersection|-X|--xor)
local orig="$cur"
# split words (by ,-not-in-brackets and &)
# Note completions with & are mostly borked
while true; do
case "$cur" in
*"&"*)
# cannot handle & without some bash-completion-fu,
# because it tries to simplify &'s escaping and then
# fails as that splits commands... Just give up.
return
;;
*"["*"]"*,*)
# complete set, remove one word
cur="${cur#*,}"
;;
*"["*)
# open bracket: leave as is
break
;;
*,*)
# no brackets, remove one word
cur="${cur#*,}"
;;
*)
# nothing left to do
break
;;
esac
done
case "$cur" in
*:*)
groupsource="${cur%%:*}"
@@ -56,6 +85,11 @@ _cluset()
if [ -n "$cleangroup" ]; then
options=${options//@"$groupsource":/@}
fi
if [ "$orig" != "$cur" ]; then
local prefix=${orig%$cur}
options="$prefix${options//$'\n'/&"$prefix"}"
cur="$orig"
fi
;;
-s|--groupsource)
options=$(cluset --groupsources --quiet)
34 changes: 34 additions & 0 deletions bash_completion.d/clush
Original file line number Diff line number Diff line change
@@ -40,6 +40,35 @@ _clush()

case "$prev" in
-w|-x|-g|--group|-X)
local orig="$cur"
# split words (by ,-not-in-brackets and &)
# Note completions with & are mostly borked
while true; do
case "$cur" in
*"&"*)
# cannot handle & without some bash-completion-fu,
# because it tries to simplify &'s escaping and then
# fails as that splits commands... Just give up.
return
;;
*"["*"]"*,*)
# complete set, remove one word
cur="${cur#*,}"
;;
*"["*)
# open bracket: leave as is
break
;;
*,*)
# no brackets, remove one word
cur="${cur#*,}"
;;
*)
# nothing left to do
break
;;
esac
done
case "$cur" in
*:*)
groupsource="${cur%%:*}"
@@ -63,6 +92,11 @@ _clush()
options=${options//@/}
;;
esac
if [ "$orig" != "$cur" ]; then
local prefix=${orig%$cur}
options="$prefix${options//$'\n'/&"$prefix"}"
cur="$orig"
fi
;;
-s|--groupsource)
options=$(cluset --groupsources --quiet)