@@ -5,6 +5,10 @@ _clush_command_or_file() {
5
5
# undo our nospace setting...
6
6
compopt +o nospace
7
7
8
+ # skip if shortopt is set -- these helpers cannot "restore" shortopt at start of
9
+ # the completions they provide easily
10
+ [ -n "$shortopt" ] && return
11
+
8
12
# complete either files (copy mode) or commands (if target set)
9
13
case "$target_set,$mode" in
10
14
*,copy)
@@ -32,6 +36,7 @@ _clush()
32
36
local cur prev words cword split
33
37
local i word options="" compopts="" skip=argv0 groupsource="" cleangroup=""
34
38
local mode=command target_set=""
39
+ local shortopt=""
35
40
36
41
_init_completion -s -n : || return
37
42
@@ -76,6 +81,15 @@ _clush()
76
81
esac
77
82
done
78
83
84
+ # split short opts without space...
85
+ case "$cur" in
86
+ -[a-z]*)
87
+ shortopt="${cur:0:2}"
88
+ prev="$shortopt"
89
+ cur="${cur:2}"
90
+ ;;
91
+ esac
92
+
79
93
case "$prev" in
80
94
-w|-x|-g|--group|-X)
81
95
case "$cur" in
@@ -134,7 +148,9 @@ _clush()
134
148
fi
135
149
136
150
# append space for everything that doesn't end in `:` (likely a groupsource)
137
- mapfile -t COMPREPLY < <(compgen -W "$options" -- "$cur" | sed -e 's/[^:]$/& /')
151
+ mapfile -t COMPREPLY \
152
+ < <(compgen -W "$options" -- "$cur" \
153
+ | sed -e 's/[^:]$/& /' -e "s/^/$shortopt/")
138
154
# remove the prefix from COMPREPLY if $cur contains colons and
139
155
# COMP_WORDBREAKS splits on colons...
140
156
__ltrim_colon_completions "$cur"
0 commit comments