134 lines · 3.4 KB · executable
#!/usr/bin/env bash
set -euo pipefail

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

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

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

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"
}

SKIP="$(status "SKIP" "$BLUE" "$WHITE")"
LINKED="$(status "LINKED" "$GREEN" "$BLACK")"
BACKUP="$(status "BACKUP" "$YELLOW" "$BLACK")"
UNLINKED="$(status "UNLINK" "$GREEN" "$BLACK")"

link() {
    local op="$1"
    local source="$PWD/$2"
    local target="$3"

    if [[ $op == "remove" ]]; then
        # Remove symlink.