From 25654c4e13180c73cc3b7cee5420e11c0fb54f9e Mon Sep 17 00:00:00 2001 From: Chris Gibson Date: Wed, 8 Mar 2017 14:19:45 +0800 Subject: [PATCH] Fix fish autocompletion with custom ps output In the docker config.json, if `psFormat` or `imagesFormat` is set to a non-standard format, it breaks autocompletion. This fixes the issue by using a custom format. Signed-off-by: Chris Gibson --- contrib/completion/fish/docker.fish | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/completion/fish/docker.fish b/contrib/completion/fish/docker.fish index d3ebcf1837..f3dddd9277 100644 --- a/contrib/completion/fish/docker.fish +++ b/contrib/completion/fish/docker.fish @@ -26,20 +26,20 @@ end function __fish_print_docker_containers --description 'Print a list of docker containers' -a select switch $select case running - docker ps -a --no-trunc | command awk 'NR>1' | command awk 'BEGIN {FS=" +"}; $5 ~ "^Up" {print $1 "\n" $(NF)}' | tr ',' '\n' + docker ps -a --no-trunc --filter status=running --format "{{.ID}}\n{{.Names}}" | tr ',' '\n' case stopped - docker ps -a --no-trunc | command awk 'NR>1' | command awk 'BEGIN {FS=" +"}; $5 ~ "^Exit" {print $1 "\n" $(NF)}' | tr ',' '\n' + docker ps -a --no-trunc --filter status=exited --format "{{.ID}}\n{{.Names}}" | tr ',' '\n' case all - docker ps -a --no-trunc | command awk 'NR>1' | command awk 'BEGIN {FS=" +"}; {print $1 "\n" $(NF)}' | tr ',' '\n' + docker ps -a --no-trunc --format "{{.ID}}\n{{.Names}}" | tr ',' '\n' end end function __fish_print_docker_images --description 'Print a list of docker images' - docker images | command awk 'NR>1' | command grep -v '' | command awk '{print $1":"$2}' + docker images --format "{{.Repository}}:{{.Tag}}" | command grep -v '' end function __fish_print_docker_repositories --description 'Print a list of docker repositories' - docker images | command awk 'NR>1' | command grep -v '' | command awk '{print $1}' | command sort | command uniq + docker images --format "{{.Repository}}" | command grep -v '' | command sort | command uniq end # common options