mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Limit commands to containers of a relevant state
This commit is contained in:
parent
4cb57a5438
commit
44eb1b3892
1 changed files with 29 additions and 15 deletions
|
@ -22,13 +22,27 @@
|
||||||
# must have access to the socket for the completions to function correctly
|
# must have access to the socket for the completions to function correctly
|
||||||
|
|
||||||
have docker && {
|
have docker && {
|
||||||
__docker_containers()
|
__docker_containers_all()
|
||||||
{
|
{
|
||||||
local containers
|
local containers
|
||||||
containers="$( docker ps -a -q )"
|
containers="$( docker ps -a -q )"
|
||||||
COMPREPLY=( $( compgen -W "$containers" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "$containers" -- "$cur" ) )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__docker_containers_running()
|
||||||
|
{
|
||||||
|
local containers
|
||||||
|
containers="$( docker ps -q )"
|
||||||
|
COMPREPLY=( $( compgen -W "$containers" -- "$cur" ) )
|
||||||
|
}
|
||||||
|
|
||||||
|
__docker_containers_stopped()
|
||||||
|
{
|
||||||
|
local containers
|
||||||
|
containers="$( comm -13 <(docker ps -q | sort -u) <(docker ps -a -q | sort -u) )"
|
||||||
|
COMPREPLY=( $( compgen -W "$containers" -- "$cur" ) )
|
||||||
|
}
|
||||||
|
|
||||||
__docker_image_repos()
|
__docker_image_repos()
|
||||||
{
|
{
|
||||||
local repos
|
local repos
|
||||||
|
@ -85,7 +99,7 @@ _docker_docker()
|
||||||
_docker_attach()
|
_docker_attach()
|
||||||
{
|
{
|
||||||
if [ $cpos -eq $cword ]; then
|
if [ $cpos -eq $cword ]; then
|
||||||
__docker_containers
|
__docker_containers_running
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +138,7 @@ _docker_commit()
|
||||||
COMPREPLY=( $( compgen -W "-author -m -run" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "-author -m -run" -- "$cur" ) )
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
__docker_containers
|
__docker_containers_all
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -132,7 +146,7 @@ _docker_commit()
|
||||||
_docker_diff()
|
_docker_diff()
|
||||||
{
|
{
|
||||||
if [ $cpos -eq $cword ]; then
|
if [ $cpos -eq $cword ]; then
|
||||||
__docker_containers
|
__docker_containers_all
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +158,7 @@ _docker_events()
|
||||||
_docker_export()
|
_docker_export()
|
||||||
{
|
{
|
||||||
if [ $cpos -eq $cword ]; then
|
if [ $cpos -eq $cword ]; then
|
||||||
__docker_containers
|
__docker_containers_all
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +226,7 @@ _docker_inspect()
|
||||||
|
|
||||||
_docker_kill()
|
_docker_kill()
|
||||||
{
|
{
|
||||||
__docker_containers
|
__docker_containers_running
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_login()
|
_docker_login()
|
||||||
|
@ -223,14 +237,14 @@ _docker_login()
|
||||||
_docker_logs()
|
_docker_logs()
|
||||||
{
|
{
|
||||||
if [ $cpos -eq $cword ]; then
|
if [ $cpos -eq $cword ]; then
|
||||||
__docker_containers
|
__docker_containers_all
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_port()
|
_docker_port()
|
||||||
{
|
{
|
||||||
if [ $cpos -eq $cword ]; then
|
if [ $cpos -eq $cword ]; then
|
||||||
__docker_containers
|
__docker_containers_all
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +278,7 @@ _docker_restart()
|
||||||
COMPREPLY=( $( compgen -W "-t" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "-t" -- "$cur" ) )
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
__docker_containers
|
__docker_containers_all
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -276,7 +290,7 @@ _docker_rm()
|
||||||
COMPREPLY=( $( compgen -W "-v" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "-v" -- "$cur" ) )
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
__docker_containers
|
__docker_containers_stopped
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -293,7 +307,7 @@ _docker_run()
|
||||||
_filedir
|
_filedir
|
||||||
;;
|
;;
|
||||||
-volumes-from)
|
-volumes-from)
|
||||||
__docker_containers
|
__docker_containers_all
|
||||||
;;
|
;;
|
||||||
-a|-c|-dns|-e|-entrypoint|-h|-m|-p|-u|-v)
|
-a|-c|-dns|-e|-entrypoint|-h|-m|-p|-u|-v)
|
||||||
return
|
return
|
||||||
|
@ -343,7 +357,7 @@ _docker_search()
|
||||||
|
|
||||||
_docker_start()
|
_docker_start()
|
||||||
{
|
{
|
||||||
__docker_containers
|
__docker_containers_stopped
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_stop()
|
_docker_stop()
|
||||||
|
@ -361,7 +375,7 @@ _docker_stop()
|
||||||
COMPREPLY=( $( compgen -W "-t" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "-t" -- "$cur" ) )
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
__docker_containers
|
__docker_containers_running
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -374,7 +388,7 @@ _docker_tag()
|
||||||
_docker_top()
|
_docker_top()
|
||||||
{
|
{
|
||||||
if [ $cpos -eq $cword ]; then
|
if [ $cpos -eq $cword ]; then
|
||||||
__docker_containers
|
__docker_containers_running
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,7 +399,7 @@ _docker_version()
|
||||||
|
|
||||||
_docker_wait()
|
_docker_wait()
|
||||||
{
|
{
|
||||||
__docker_containers
|
__docker_containers_all
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker()
|
_docker()
|
||||||
|
|
Loading…
Reference in a new issue