157 lines · 4.2 KB · executable
#!/usr/bin/env bash
set -euo pipefail

source "$PWD/modules/home/bash/bash_funcs"

usage() {
    echo "Usage: $0 [link|remove|update]"
    exit 1
}

OP="${1:-}"
if [[ "$OP" == "" ]]; then
    OP="link"
fi

if [[ "$OP" != "link" && "$OP" != "remove" && "$OP" != "update" ]]; then
    usage
fi

GREEN_CHECK="$(printf '\x1b[32m✓\x1b[m')"

BLACK=0
GREEN=2
YELLOW=3
BLUE=4
WHITE=7

# Print a status message with colors.
status() {
    local text="$1"
    local bg_color="$2"
    local fg_color="$3"

    # Convert color numbers to ANSI codes
    local bg_code=$((bg_color < 8 ? bg_color + 40 : bg_color + 92))
    local fg_code=$((fg_color < 8 ? fg_color + 30 : fg_color + 82))

    local padding
    padding=6
    printf "\x1b[1;${bg_code};${fg_code}m %-${padding}s \x1b[m" "$text"