From 7dd13896cd906d07f22819e85c9ac9d19310122d Mon Sep 17 00:00:00 2001 From: Brian Zalewski Date: Mon, 31 Oct 2022 20:39:24 +0000 Subject: [PATCH] Update dotfiles/.local/motd.sh, dotfiles/.profile --- dotfiles/.local/motd.sh | 33 +++++++++++++++++---------------- dotfiles/.profile | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/dotfiles/.local/motd.sh b/dotfiles/.local/motd.sh index 27cf091e..39e12371 100644 --- a/dotfiles/.local/motd.sh +++ b/dotfiles/.local/motd.sh @@ -208,7 +208,7 @@ print_banner() { figlet "$(hostname)" | lolcat -f else figlet "Manhattan" | lolcat -a -f - mkdir -p "$HOME/.local/labs" + mkdir -p "$HOME/.local/labs" > /dev/null touch "$HOME/.local/labs/term-welcome-anim" fi elif command -v figlet >/dev/null; then @@ -490,23 +490,24 @@ print_docker() { docker_images=$(echo "$docker_info" | jq -r '.Images') - printf " %s Version %s%s%s %s Images\\n\\n" "$DOCKER_VERSION_ICON" "$docker_version" "$docker_space" "$DOCKER_IMAGES_ICON" "$docker_images" + printf " %s Version %s%s%s %s Images\\n" "$DOCKER_VERSION_ICON" "$docker_version" "$docker_space" "$DOCKER_IMAGES_ICON" "$docker_images" - docker_list=$(sudo curl -sf --unix-socket /var/run/docker.sock "http://v1.40/containers/json?all=true" | jq -c ' .[]') + docker_list_curl="$(sudo curl -sf --unix-socket /var/run/docker.sock "http://v1.40/containers/json?all=true")" + docker_list_curl_length="$(echo "$docker_list_curl" | jq -c '. | length')" + docker_list="$(echo "$docker_list_curl" | jq -c ' .[]')" - echo "$docker_list" | while read -r line; do - container_name="$(echo "$line" | jq -r '.Names[]' | sed 's/\///')" - - container_status="$(echo "$line" | jq -r '.Status' | sed 's/.*/\l&/')" - - container_space=$(generate_space "$container_name" 34) - - if [ "$(echo "$line" | jq -r '.State')" = "running" ]; then - printf " \\033[%um%s\\033[0m %s%s%s\\n" "$DOCKER_RUNNING_COLOR" "$DOCKER_RUNNING_ICON" "$container_name" "$container_space" "$container_status" - else - printf " \\033[%um%s\\033[0m \\033[%um%s\\033[0m%s\\033[%um%s\\033[0m\\n" "$DOCKER_OTHER_COLOR" "$DOCKER_OTHER_ICON" "$DOCKER_OTHER_COLOR" "$container_name" "$container_space" "$DOCKER_OTHER_COLOR" "$container_status" - fi - done + if [ "$docker_list_curl_length" != '0' ]; then + echo "$docker_list" | while read -r line; do + container_name="$(echo "$line" | jq -r '.Names[]' | sed 's/\///')" + container_status="$(echo "$line" | jq -r '.Status' | sed 's/.*/\l&/')" + container_space=$(generate_space "$container_name" 34) + if [ "$(echo "$line" | jq -r '.State')" = "running" ]; then + printf " \\033[%um%s\\033[0m %s%s%s\\n" "$DOCKER_RUNNING_COLOR" "$DOCKER_RUNNING_ICON" "$container_name" "$container_space" "$container_status" + else + printf " \\033[%um%s\\033[0m \\033[%um%s\\033[0m%s\\033[%um%s\\033[0m\\n" "$DOCKER_OTHER_COLOR" "$DOCKER_OTHER_ICON" "$DOCKER_OTHER_COLOR" "$container_name" "$container_space" "$DOCKER_OTHER_COLOR" "$container_status" + fi + done + fi fi } diff --git a/dotfiles/.profile b/dotfiles/.profile index 717751b1..e1bec83d 100644 --- a/dotfiles/.profile +++ b/dotfiles/.profile @@ -43,7 +43,7 @@ if [ "$0" = 'bash' ] || [ "$0" = '/bin/bash' ] || [ "$0" = 'zsh' ] || [ "$0" = ' . /etc/os-release if [ "$ID" = 'alpine' ]; then OS_ICON="" - elif [ "$ID" = 'archlinux' ]; then + elif [ "$ID" = 'arch' ]; then OS_ICON="" elif [ "$ID" = 'centos' ]; then OS_ICON=""