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 <chris@chrisg.io>
This commit is contained in:
Chris Gibson 2017-03-08 14:19:45 +08:00
parent 193730bec1
commit b4a1634cec

View file

@ -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 '<none>' | command awk '{print $1":"$2}'
docker images --format "{{.Repository}}:{{.Tag}}" | command grep -v '<none>'
end
function __fish_print_docker_repositories --description 'Print a list of docker repositories'
docker images | command awk 'NR>1' | command grep -v '<none>' | command awk '{print $1}' | command sort | command uniq
docker images --format "{{.Repository}}" | command grep -v '<none>' | command sort | command uniq
end
# common options