<commit_before>#!/usr/local/bin/fish
# <bitbar.title>Docker status information</bitbar.title>
# <bitbar.author><NAME></bitbar.author>
# <bitbar.author.github>sebastianmarkow</bitbar.author.github>
# <bitbar.desc>List running Docker machines</bitbar.desc>
# <bitbar.dependencies>fish</bitbar.dependencies>

set -l dm (command -s docker-machine)
or exit 1
set -l d (command -s docker)
or exit 1

set -l icon "<KEY>"

set -l machines (command docker-machine ls --format "{{.Name}}|{{.State}}")
set -l num (count (echo $machines | grep 'Running'))

for machine in $machines
    set -l label (echo $machine | cut -d "|" -f 1)
    set -l state (echo $machine | cut -d "|" -f 2)
    switch "$state"
        case 'Running'
            set items $items "$label| color=green terminal=false refresh=true bash=$dm param1=stop param2=$label"
            eval (command docker-machine env --shell fish "$label" | sed 's/\-gx/\-x/g')
            set -l containers (command docker ps -a --format "{{.Names}} ({{.Image}})|{{.ID}}|{{.Status}}")
            for container in $containers
                set -l clabel (echo $container | cut -d "|" -f 1)
                set -l cid (echo $container | cut -d "|" -f 2)
                set -l cstatus (echo $container | cut -d "|" -f 3)
                switch "$cstatus"
                    case 'Up*'
                        set ccolor "color=green"
                        set ccmd "stop"
                    case 'Exited*'
                        set ccolor "color=red"
                        set ccmd "start"
                end
                if test "$container" = "$containers[-1]"
                    set sym "└"
                else
                    set sym "├"
                end
                set items $items "$sym $clabel| $ccolor terminal=false refresh=true bash=$d param1=$ccmd param2=$cid"
            end
        case '*'
            set items $items "$label| color=red terminal=false refresh=true bash=$dm param1=start param2=$label"
    end
end

if test $num -gt 0
    set sym "$num"
end

echo "$sym| templateImage=$icon dropdown=false"
echo "---"
for item in $items
    echo $item
end<commit_msg>bitbar: Add separator between docker machines<commit_after>#!/usr/local/bin/fish
# <bitbar.title>Docker status information</bitbar.title>
# <bitbar.author><NAME></bitbar.author>
# <bitbar.author.github>sebastianmarkow</bitbar.author.github>
# <bitbar.desc>List running Docker machines</bitbar.desc>
# <bitbar.dependencies>fish</bitbar.dependencies>

set -l dm (command -s docker-machine)
or exit 1
set -l d (command -s docker)
or exit 1

set -l icon "<KEY>"

set -l machines (command docker-machine ls --format "{{.Name}}|{{.State}}")
set -l num (count (echo $machines | grep 'Running'))

for machine in $machines
    set -l label (echo $machine | cut -d "|" -f 1)
    set -l state (echo $machine | cut -d "|" -f 2)
    switch "$state"
        case 'Running'
            set items $items "$label ($state)| color=green terminal=false refresh=true bash=$dm param1=stop param2=$label"
            eval (command docker-machine env --shell fish "$label" | sed 's/\-gx/\-x/g')
            set -l containers (command docker ps -a --format "{{.Names}} ({{.Image}})|{{.ID}}|{{.Status}}")
            for container in $containers
                set -l clabel (echo $container | cut -d "|" -f 1)
                set -l cid (echo $container | cut -d "|" -f 2)
                set -l cstatus (echo $container | cut -d "|" -f 3)
                switch "$cstatus"
                    case 'Up*'
                        set ccolor "color=green"
                        set ccmd "stop"
                    case 'Exited*'
                        set ccolor "color=red"
                        set ccmd "start"
                end
                if test "$container" = "$containers[-1]"
                    set sym "└"
                else
                    set sym "├"
                end
                set items $items "$sym $clabel| $ccolor terminal=false refresh=true bash=$d param1=$ccmd param2=$cid"
            end
        case '*'
            set items $items "$label ($state)| color=red terminal=false refresh=true bash=$dm param1=start param2=$label"
    end
end

if test $num -gt 0
    set sym "$num"
end

echo "$sym| templateImage=$icon dropdown=false"
echo "---"
for item in $items
    echo $item
    echo "---"
end
{'fraction_non_alphanumeric': 0.1402061855670103, 'fraction_numerical': 0.006872852233676976, 'mean_word_length': 1.9126084056037358, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6572965', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1303, 'n_words': 431}