From 2bbb59964fadff0f87989ec3f1f32a7c2dac9a05 Mon Sep 17 00:00:00 2001 From: David Flores Date: Fri, 18 Apr 2014 18:13:10 -0500 Subject: [PATCH] functions on top --- share/completions/docker.fish | 50 +++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/share/completions/docker.fish b/share/completions/docker.fish index 31b83f9a5..589e79c43 100644 --- a/share/completions/docker.fish +++ b/share/completions/docker.fish @@ -2,6 +2,33 @@ # Completions for the docker command # +# +# Functions +# + +function __fish_docker_using_command + set cmd (commandline -opc) + if [ (count $cmd) -gt 1 ] + if [ $argv[1] = $cmd[2] ] + return 0 + end + end + return 1 +end + +function __fish_docker_all_containers --description "Show all containers" + command docker ps -q -a +end + + +function __fish_docker_start_containers --description "Show the running containers" + command docker ps -q +end + +function __fish_docker_stop_containers --description "Show the exited containers" + command docker ps -a | grep "Exit" | awk '{ print $1 }' +end + # All docker commands complete -c docker -n '__fish_use_subcommand' -xa attach --description "Attach to a running container" complete -c docker -n '__fish_use_subcommand' -xa build --description "Build a container from a Dockerfile" @@ -37,29 +64,6 @@ complete -c docker -n '__fish_use_subcommand' -xa top --description "Lookup the complete -c docker -n '__fish_use_subcommand' -xa version --description "Show the docker version information" complete -c docker -n '__fish_use_subcommand' -xa wait --description "Block until a container stops, then print its exit code" -function __fish_docker_using_command - set cmd (commandline -opc) - if [ (count $cmd) -gt 1 ] - if [ $argv[1] = $cmd[2] ] - return 0 - end - end - return 1 -end - -function __fish_docker_all_containers --description "Show all containers" - command docker ps -q -a -end - - -function __fish_docker_start_containers --description "Show the running containers" - command docker ps -q -end - -function __fish_docker_stop_containers --description "Show the exited containers" - command docker ps -a | grep "Exit" | awk '{ print $1 }' -end - # # docker ps #