Update dotfiles/.local/motd.sh, dotfiles/.local/dockerfunc.sh, dotfiles/.local/antigen.zsh

This commit is contained in:
Brian Zalewski 2022-10-28 19:34:31 +00:00
parent 2983a47753
commit a11873b099
3 changed files with 426 additions and 424 deletions

View file

@ -1,5 +1,5 @@
#!/bin/bash #!/usr/bin/env bash
# Bash wrappers for docker run commands # Bash wrappers for docker run commands
# Source: https://github.com/jessfraz/dotfiles/blob/master/.dockerfunc # Source: https://github.com/jessfraz/dotfiles/blob/master/.dockerfunc

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/usr/bin/env sh
# shellcheck disable=SC1090,SC1091 # shellcheck disable=SC1090,SC1091
BAR_ELEMENT="-" BAR_ELEMENT="-"
@ -93,12 +93,12 @@ generate_space() {
# 1 - already used # 1 - already used
# 2 - total # 2 - total
space_fill=$(( $2 - ${#1} )) space_fill=$(($2 - ${#1}))
space_chars="" space_chars=""
while [ $space_fill -ge 0 ]; do while [ $space_fill -ge 0 ]; do
space_chars="$space_chars " space_chars="$space_chars "
space_fill=$(( space_fill - 1 )) space_fill=$((space_fill - 1))
done done
echo "$space_chars" echo "$space_chars"
@ -110,8 +110,8 @@ generate_bar() {
# 3 - used_1 # 3 - used_1
# 4 - [ used_2 ] # 4 - [ used_2 ]
bar_percent=$(( $3 * 100 / $2 )) bar_percent=$(($3 * 100 / $2))
bar_separator=$(( $3 * 100 * 10 / $2 / 25 )) bar_separator=$(($3 * 100 * 10 / $2 / 25))
if [ $bar_percent -ge "$BAR_WARNING_THRESHOLD" ]; then if [ $bar_percent -ge "$BAR_WARNING_THRESHOLD" ]; then
bar_color=$BAR_WARNING_COLOR bar_color=$BAR_WARNING_COLOR
@ -123,7 +123,7 @@ generate_bar() {
printf " %s \\033[%dm" "$1" "$bar_color" printf " %s \\033[%dm" "$1" "$bar_color"
if [ -z "$4" ] ; then if [ -z "$4" ]; then
bar_piece=0 bar_piece=0
while [ $bar_piece -le 40 ]; do while [ $bar_piece -le 40 ]; do
if [ "$bar_piece" -ne "$bar_separator" ]; then if [ "$bar_piece" -ne "$bar_separator" ]; then
@ -132,11 +132,11 @@ generate_bar() {
printf "%s\\033[1;30m" "$BAR_ELEMENT" printf "%s\\033[1;30m" "$BAR_ELEMENT"
fi fi
bar_piece=$(( bar_piece + 1 )) bar_piece=$((bar_piece + 1))
done done
else else
bar_cached_val=$(( $3 + $4 )) bar_cached_val=$(($3 + $4))
bar_cached_separator=$(( bar_cached_val * 100 * 10 / $2 / 25 )) bar_cached_separator=$((bar_cached_val * 100 * 10 / $2 / 25))
bar_piece=0 bar_piece=0
while [ $bar_piece -le 40 ]; do while [ $bar_piece -le 40 ]; do
@ -148,7 +148,7 @@ generate_bar() {
printf "%s" "$BAR_ELEMENT" printf "%s" "$BAR_ELEMENT"
fi fi
bar_piece=$(( bar_piece + 1 )) bar_piece=$((bar_piece + 1))
done done
fi fi
@ -163,7 +163,7 @@ generate_bar_memory() {
bar_memory_used=$(generate_unit_byte "$3") bar_memory_used=$(generate_unit_byte "$3")
bar_memory_cached=$(generate_unit_byte "$4") bar_memory_cached=$(generate_unit_byte "$4")
bar_memory_available=$(generate_unit_byte $(( $2 - $3 )) ) bar_memory_available=$(generate_unit_byte $(($2 - $3)))
printf " %s used / %s cached / %s available\\n" "$bar_memory_used" "$bar_memory_cached" "$bar_memory_available" printf " %s used / %s cached / %s available\\n" "$bar_memory_used" "$bar_memory_cached" "$bar_memory_available"
generate_bar "$1" "$2" "$3" "$4" generate_bar "$1" "$2" "$3" "$4"
@ -176,7 +176,7 @@ generate_bar_swap() {
bar_swap_used=$(generate_unit_byte "$3") bar_swap_used=$(generate_unit_byte "$3")
bar_swap_available=$(( $2 - $3 )) bar_swap_available=$(($2 - $3))
bar_swap_available=$(generate_unit_byte "$bar_swap_available") bar_swap_available=$(generate_unit_byte "$bar_swap_available")
printf " %s used / %s available\\n" "$bar_swap_used" "$bar_swap_available" printf " %s used / %s available\\n" "$bar_swap_used" "$bar_swap_available"
@ -194,7 +194,7 @@ generate_bar_disk() {
bar_disk_used=$(generate_unit_byte "$3") bar_disk_used=$(generate_unit_byte "$3")
bar_disk_used="$(generate_space "$bar_disk_used" 5)$bar_disk_used used" bar_disk_used="$(generate_space "$bar_disk_used" 5)$bar_disk_used used"
bar_disk_available=$(( $2 - $3 )) bar_disk_available=$(($2 - $3))
bar_disk_available="$(generate_unit_byte "$bar_disk_available") available" bar_disk_available="$(generate_unit_byte "$bar_disk_available") available"
printf " %s%s / %s\\n" "$bar_disk_mount" "$bar_disk_used" "$bar_disk_available" printf " %s%s / %s\\n" "$bar_disk_mount" "$bar_disk_used" "$bar_disk_available"
@ -258,7 +258,7 @@ print_processor() {
processor_model="$(echo "$processor_info" | grep "model name" | sort -u | cut -d ':' -f 2)" processor_model="$(echo "$processor_info" | grep "model name" | sort -u | cut -d ':' -f 2)"
processor_count=$(echo "$processor_info" | grep "physical id" | sort -u | wc -l) processor_count=$(echo "$processor_info" | grep "physical id" | sort -u | wc -l)
processor_cores=$(echo "$processor_info" | grep "cpu cores" | sort -u | cut -d ':' -f 2) processor_cores=$(echo "$processor_info" | grep "cpu cores" | sort -u | cut -d ':' -f 2)
processor_threads=$(( $(echo "$processor_info" | grep "siblings" | tail -n 1 | cut -d ':' -f 2) )) processor_threads=$(($(echo "$processor_info" | grep "siblings" | tail -n 1 | cut -d ':' -f 2)))
if [ ! "$processor_cores" -eq $processor_threads ]; then if [ ! "$processor_cores" -eq $processor_threads ]; then
processor_threads=", $processor_threads Threads" processor_threads=", $processor_threads Threads"
@ -284,7 +284,7 @@ print_processor() {
processor_model=$(echo "$processor_model" | sed "s/ / /") processor_model=$(echo "$processor_model" | sed "s/ / /")
processor_model=$(echo "$processor_model" | sed "s/^ //g") processor_model=$(echo "$processor_model" | sed "s/^ //g")
processor_cores=$(( processor_cores * processor_count )) processor_cores=$((processor_cores * processor_count))
if [ "$processor_count" -gt 1 ]; then if [ "$processor_count" -gt 1 ]; then
processor_count="$processor_count""x " processor_count="$processor_count""x "
@ -323,6 +323,7 @@ print_swap() {
} }
print_diskspace() { print_diskspace() {
if type jq > /dev/null; then
printf "\\n" printf "\\n"
printf " \\033[1;37mDiskspace:\\033[0m\\n" printf " \\033[1;37mDiskspace:\\033[0m\\n"
@ -349,14 +350,15 @@ print_diskspace() {
printf "\\n" printf "\\n"
fi fi
diskspace_index=$(( diskspace_index + 1 )) diskspace_index=$((diskspace_index + 1))
generate_bar_disk "$DISKSPACE_ICON" "$diskspace_disk_size" "$diskspace_disk_used" "$diskspace_disk_mount" generate_bar_disk "$DISKSPACE_ICON" "$diskspace_disk_size" "$diskspace_disk_used" "$diskspace_disk_mount"
done done
fi
} }
print_services() { print_services() {
if [ -f $SERVICES_FILE ] && [ "$(wc -l < $SERVICES_FILE )" != 0 ]; then if [ -f $SERVICES_FILE ] && [ "$(wc -l < $SERVICES_FILE)" != 0 ]; then
printf "\\n" printf "\\n"
printf " \\033[1;37mServices:\\033[0m \\033[1;37mVersion:\\033[0m\\n" printf " \\033[1;37mServices:\\033[0m \\033[1;37mVersion:\\033[0m\\n"
@ -554,7 +556,7 @@ print_letsencrypt() {
print_login() { print_login() {
login_last=$(last -n 2 -a -d --time-format iso "$(whoami)" | head -n 2 | tail -n 1) login_last=$(last -n 2 -a -d --time-format iso "$(whoami)" | head -n 2 | tail -n 1)
if [ "$( echo "$login_last" | awk '{ print $1 }')" = "$(whoami)" ]; then if [ "$(echo "$login_last" | awk '{ print $1 }')" = "$(whoami)" ]; then
login_ip=$(echo "$login_last" | awk '{ print $7 }') login_ip=$(echo "$login_last" | awk '{ print $7 }')
login_login=$(date -d "$(echo "$login_last" | awk '{ print $3 }' | cut -d '+' -f 1 | sed "s/T/ /")" "+%a, %d.%m.%y %H:%M") login_login=$(date -d "$(echo "$login_last" | awk '{ print $3 }' | cut -d '+' -f 1 | sed "s/T/ /")" "+%a, %d.%m.%y %H:%M")