Skip to content
Open
Show file tree
Hide file tree
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
Expand Up @@ -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%%:*}"
Expand All @@ -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)
Expand Down
34 changes: 34 additions & 0 deletions bash_completion.d/clush
Original file line number Diff line number Diff line change
Expand Up @@ -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%%:*}"
Expand All @@ -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)
Expand Down
Loading