Skip to content
Merged
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
18 changes: 17 additions & 1 deletion bash_completion.d/clush
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ _clush_command_or_file() {
# undo our nospace setting...
compopt +o nospace

# skip if shortopt is set -- these helpers cannot "restore" shortopt at start of
# the completions they provide easily
[ -n "$shortopt" ] && return

# complete either files (copy mode) or commands (if target set)
case "$target_set,$mode" in
*,copy)
Expand Down Expand Up @@ -32,6 +36,7 @@ _clush()
local cur prev words cword split
local i word options="" compopts="" skip=argv0 groupsource="" cleangroup=""
local mode=command target_set=""
local shortopt=""

_init_completion -s -n : || return

Expand Down Expand Up @@ -76,6 +81,15 @@ _clush()
esac
done

# split short opts without space...
case "$cur" in
-[a-z]*)
shortopt="${cur:0:2}"
prev="$shortopt"
cur="${cur:2}"
;;
esac

case "$prev" in
-w|-x|-g|--group|-X)
case "$cur" in
Expand Down Expand Up @@ -134,7 +148,9 @@ _clush()
fi

# append space for everything that doesn't end in `:` (likely a groupsource)
mapfile -t COMPREPLY < <(compgen -W "$options" -- "$cur" | sed -e 's/[^:]$/& /')
mapfile -t COMPREPLY \
< <(compgen -W "$options" -- "$cur" \
| sed -e 's/[^:]$/& /' -e "s/^/$shortopt/")
# remove the prefix from COMPREPLY if $cur contains colons and
# COMP_WORDBREAKS splits on colons...
__ltrim_colon_completions "$cur"
Expand Down
Loading