summaryrefslogtreecommitdiff
path: root/.config/fish/conf.d/halostatue_fish_docker.fish
blob: 959da8d1ffd54e00be2b7d7c3bd99fb936693cad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function _halostatue_fish_docker_uninstall -e halostatue_fish_docker_uninstall
    functions -e (functions -a | command awk '/_halostatue_fish_docker_/')
end

function _halostatue_fish_docker_print_containers --description 'Print a list of docker containers' -a select append
    set -l filter
    switch $select
        case running
            set filter --filter status=running
        case stopped
            set filter --filter status=exited
        case '*'
            set filter --all
    end

    test -z $append; and set append ''

    docker ps --no-trunc $filter --format '{{.ID}}\n{{.Names}}' | tr ',' $append'\n'
end

function _halostatue_fish_docker_print_images --description 'Print a list of docker images'
    docker images --format '{{if eq .Repository "<none>"}}{{.ID}}\tUnnamed Image{{else}}{{.Repository}}:{{.Tag}}{{end}}'
end

function _halostatue_fish_docker_print_repositories --description 'Print a list of docker repositories'
    docker images --format '{{.Repository}}' | command grep -v '<none>' | command sort | command uniq
end

function _halostatue_fish_docker_print_compose_services --description 'Print a list of docker-compose services'
    docker-compose config --services 2>/dev/null | command sort
end