Skip to content

Commit 216135e

Browse files
committed
feat(sudo): more option argument (non-)completions
--chdir, --host, --chroot, --role, --command-timeout, --type and corresponding short options.
1 parent b9bf770 commit 216135e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

completions/sudo

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ _comp_cmd_sudo()
88
local i mode=normal
99
[[ $1 == *sudoedit ]] && mode=edit
1010

11-
local noargopts='!(-*|*[CgpUu]*)'
11+
local noargopts='!(-*|*[CDghpRrTtUu]*)'
1212
[[ $mode == normal ]] &&
1313
for ((i = 1; i <= cword; i++)); do
1414
if [[ ${words[i]} != -* ]]; then
@@ -23,7 +23,7 @@ _comp_cmd_sudo()
2323
break
2424
fi
2525
# shellcheck disable=SC2254
26-
[[ ${words[i]} == @(--@(close-from|group|prompt|other-user|user)|-${noargopts}[CgpUu]) ]] &&
26+
[[ ${words[i]} == @(--@(close-from|chdir|group|host|prompt|chroot|role|command-timeout|type|other-user|user)|-${noargopts}[CDghpRrTtUu]) ]] &&
2727
((i++))
2828
done
2929

@@ -37,7 +37,16 @@ _comp_cmd_sudo()
3737
_comp_compgen -- -g
3838
return
3939
;;
40-
--close-from | --prompt | -${noargopts}[Cp])
40+
--close-from | --prompt | --role | --type | --command-timeout | \
41+
-${noargopts}[CprTt])
42+
return
43+
;;
44+
--chdir | --chroot | -${noargopts}[DR])
45+
_comp_compgen_filedir -d
46+
return
47+
;;
48+
--host | -${noargopts}h)
49+
_comp_compgen_known_hosts -- "$cur"
4150
return
4251
;;
4352
esac

0 commit comments

Comments
 (0)