Skip to content

Commit

Permalink
Improve bash completion for users and groups
Browse files Browse the repository at this point in the history
Signed-off-by: Harald Albers <[email protected]>
  • Loading branch information
albers committed Jan 28, 2016
1 parent 725b5b5 commit 0e5ea96
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions contrib/completion/bash/docker
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,15 @@ __docker_complete_signals() {
COMPREPLY=( $( compgen -W "${signals[*]} ${signals[*]#SIG}" -- "$( echo $cur | tr '[:lower:]' '[:upper:]')" ) )
}

__docker_complete_user_group() {
if [[ $cur == *:* ]] ; then
COMPREPLY=( $(compgen -g -- "${cur#*:}") )
else
COMPREPLY=( $(compgen -u -S : -- "$cur") )
__docker_nospace
fi
}

# global options that may appear after the docker command
_docker_docker() {
local boolean_options="
Expand Down Expand Up @@ -851,12 +860,7 @@ _docker_daemon() {
return
;;
--userns-remap)
if [[ $cur == *:* ]] ; then
COMPREPLY=( $(compgen -g -- "${cur#*:}") )
else
COMPREPLY=( $(compgen -u -S : -- "$cur") )
__docker_nospace
fi
__docker_complete_user_group
return
;;
$(__docker_to_extglob "$options_with_args") )
Expand Down Expand Up @@ -995,6 +999,7 @@ _docker_exec() {

case "$prev" in
--user|-u)
__docker_complete_user_group
return
;;
esac
Expand Down Expand Up @@ -1769,6 +1774,10 @@ _docker_run() {
esac
return
;;
--user|-u)
__docker_complete_user_group
return
;;
--volume-driver)
__docker_complete_plugins Volume
return
Expand Down

0 comments on commit 0e5ea96

Please sign in to comment.