@@ -129,6 +129,17 @@ __get_flux_subcommands() {
129129 echo "$subcommands"
130130}
131131
132+ # Helper to emit id.f58plain when match begins with `f`
133+ _flux_id_fmt()
134+ {
135+ local cur=$1
136+ local fmt="{id}"
137+ if [[ $cur == f* ]]; then
138+ fmt="{id.f58plain}"
139+ fi
140+ echo "${fmt}"
141+ }
142+
132143# flux-cancel(1) completions
133144_flux_cancel()
134145{
@@ -143,7 +154,7 @@ _flux_cancel()
143154 "
144155 if [[ $cur != -* ]]; then
145156 # Attempt to substitute an active jobid
146- active_jobs=$(flux jobs -no {id} )
157+ active_jobs=$(flux jobs -no $(_flux_id_fmt $cur) )
147158 COMPREPLY=( $(compgen -W "${active_jobs}" -- "$cur") )
148159 return 0
149160 fi
@@ -165,7 +176,7 @@ _flux_update()
165176 "
166177 if [[ $cur != -* ]]; then
167178 # Attempt to substitute an active jobid
168- active_jobs="$(flux jobs -no {id} )"
179+ active_jobs="$(flux jobs -no $(_flux_id_fmt $cur) )"
169180 COMPREPLY=( $(compgen -W "${active_jobs}" -- "$cur") )
170181 return 0
171182 fi
@@ -177,6 +188,40 @@ _flux_update()
177188 return 0
178189}
179190
191+ # flux-hostlist(1) completions
192+ _flux_hostlist()
193+ {
194+ local cmd=$1
195+ OPTS="\
196+ -e --expand \
197+ -d --delimiter= \
198+ -c --count \
199+ -n --nth \
200+ -L --limit= \
201+ -S --sort \
202+ -x --exclude= \
203+ -u --union --unique \
204+ -i --intersect \
205+ -m --minus \
206+ -X --xor \
207+ -f --fallback \
208+ -q --quiet \
209+ "
210+ if [[ $cur != -* ]]; then
211+ # Substitute source name or recent jobid
212+ jobs="$(flux jobs -ano $(_flux_id_fmt $cur))"
213+ sources="local instance avail stdin $jobs"
214+ COMPREPLY=( $(compgen -W "$sources $jobs" -- "$cur") )
215+ return 0
216+ fi
217+ COMPREPLY=( $(compgen -W "${OPTS} -h --help" -- "$cur") )
218+ if [[ "${COMPREPLY[@]}" == *= ]]; then
219+ # Add space if there is not a '=' in suggestions
220+ compopt -o nospace
221+ fi
222+ return 0
223+ }
224+
180225# flux-{run,submit,batch,alloc,bulksubmit}(1) completions
181226_flux_submit_commands()
182227{
@@ -516,7 +561,7 @@ _flux_job()
516561 if [[ $cur != -* ]]; then
517562 if _flux_contains_word ${cmd} ${subcmds}; then
518563 # These commands take active jobids by default:
519- active_jobs=$(flux jobs -no {id} )
564+ active_jobs=$(flux jobs -no $(_flux_id_fmt $cur) )
520565 COMPREPLY=( $(compgen -W "${active_jobs}" -- "$cur") )
521566 return 0
522567 fi
@@ -1080,7 +1125,7 @@ _flux_watch()
10801125 "
10811126 if [[ $cur != -* ]]; then
10821127 # Attempt to substitute an active jobid
1083- active_jobs=$(flux jobs -no {id} )
1128+ active_jobs=$(flux jobs -no $(_flux_id_fmt $cur) )
10841129 COMPREPLY=( $(compgen -W "${active_jobs}" -- "$cur") )
10851130 return 0
10861131 fi
@@ -1141,7 +1186,7 @@ _flux_top()
11411186 return 0
11421187 fi
11431188 # flux-top(1) can target jobids that are also instances
1144- local jobs=$(flux jobs -no {uri}:{id} | grep -v ^None: \
1189+ local jobs=$(flux jobs -no {uri}:$(_flux_id_fmt $cur) | grep -v ^None: \
11451190 | sed -n 's/.*://p')
11461191 COMPREPLY=( $(compgen -W "${OPTS} $jobs" -- "$cur") )
11471192 if [[ "${COMPREPLY[@]}" == *= ]]; then
@@ -1499,6 +1544,9 @@ _flux_core()
14991544 update)
15001545 _flux_update $subcmd
15011546 ;;
1547+ hostlist)
1548+ _flux_hostlist $subcmd
1549+ ;;
15021550 -*)
15031551 COMPREPLY=( $(compgen -W "${FLUX_OPTS}" -- "$cur") )
15041552 ;;
0 commit comments