From 0aa375f037e6ceeb2e2b5ebf3e6f72edb3be123b Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Sun, 8 Mar 2026 22:18:53 -0700 Subject: [PATCH] Add ANSI color and styling to shell scripts --- color-preview.sh | 45 +++++++++++++++++++++++++++++++++++++++++++ install/install.sh | 22 ++++++++++++--------- scripts/deploy.sh | 13 +++++++++---- src/server/install.sh | 19 +++++++++++++----- 4 files changed, 81 insertions(+), 18 deletions(-) create mode 100755 color-preview.sh diff --git a/color-preview.sh b/color-preview.sh new file mode 100755 index 0000000..c3db311 --- /dev/null +++ b/color-preview.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +b=$'\033[1m' d=$'\033[2m' g=$'\033[32m' c=$'\033[36m' y=$'\033[33m' r=$'\033[0m' + +echo "" +echo " ┌── CLI installer (curl | bash) ──────────────┐" +echo "" +echo " ${b}🐾 toes cli${r}" +echo " ${d}─────────────────────────────${r}" +echo "" +echo " ${d}Fetching macos/arm64...${r}" +echo " ${g}Installed to${r} ${b}/Users/chris/.local/bin/toes${r}" +echo "" +echo " ${y}Add /Users/chris/.local/bin to your \$PATH, then:${r}" +echo " Run ${c}toes${r} to get started." +echo "" +echo "" +echo " ┌── After deploy ─────────────────────────────┐" +echo "" +echo " ${b}${g}🐾 Deployed${r} to ${b}pi@toes.local${r}" +echo " ${d}─────────────────────────────${r}" +echo "" +echo " Dashboard: ${c}http://toes.local${r}" +echo "" +echo " ${d}Grab the CLI:${r}" +echo " ${c}curl -fsSL http://toes.local/install | bash${r}" +echo "" +echo "" +echo " ┌── After server install ─────────────────────┐" +echo "" +echo " ${d}╔══════════════════════════════════╗${r}" +echo " ${d}║${r} ${b}🐾 toes${r} ${d}- personal web appliance ║${r}" +echo " ${d}╚══════════════════════════════════╝${r}" +echo "" +echo " ${d}>>${r} Updating system packages" +echo " ${d}>>${r} Installing bun" +echo " ${d}>>${r} Building" +echo "" +echo " ${b}${g}🐾 toes abc1234 is up!${r}" +echo " ${d}─────────────────────────────${r}" +echo "" +echo " Dashboard: ${c}http://toes.local${r}" +echo "" +echo " ${d}Grab the CLI:${r}" +echo " ${c}curl -fsSL http://toes.local/install | bash${r}" +echo "" diff --git a/install/install.sh b/install/install.sh index 85f66c0..227d9eb 100644 --- a/install/install.sh +++ b/install/install.sh @@ -15,18 +15,20 @@ DATA_DIR=~/data # ── Helpers ────────────────────────────────────────────── +b=$'\033[1m' d=$'\033[2m' g=$'\033[32m' c=$'\033[36m' y=$'\033[33m' r=$'\033[0m' + quiet() { "$@" > /dev/null 2>&1; } -info() { echo ">> $1"; } +info() { echo " ${d}>>${r} $1"; } -fail() { echo "ERROR: $1" >&2; exit 1; } +fail() { echo " ${y}ERROR:${r} $1" >&2; exit 1; } # ── Preflight ──────────────────────────────────────────── echo "" -echo " ╔══════════════════════════════════╗" -echo " ║ 🐾 toes - personal web appliance ║" -echo " ╚══════════════════════════════════╝" +echo " ${d}╔══════════════════════════════════╗${r}" +echo " ${d}║${r} ${b}🐾 toes${r} ${d}- personal web appliance ║${r}" +echo " ${d}╚══════════════════════════════════╝${r}" echo "" [ "$(whoami)" = "toes" ] || fail "Must be run as the 'toes' user." @@ -125,9 +127,11 @@ sudo systemctl restart toes VERSION=$(git describe --tags --always 2>/dev/null || echo "unknown") echo "" -echo " toes $VERSION is running!" -echo " http://$(hostname).local" +echo " ${b}${g}🐾 toes $VERSION is up!${r}" +echo " ${d}─────────────────────────────${r}" echo "" -echo " Install the CLI on your local machine:" -echo " curl -fsSL http://$(hostname).local/install | bash" +echo " Dashboard: ${c}http://$(hostname).local${r}" +echo "" +echo " ${d}Grab the CLI:${r}" +echo " ${c}curl -fsSL http://$(hostname).local/install | bash${r}" echo "" diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 2070591..fb6041f 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -57,9 +57,14 @@ done sudo systemctl restart toes.service SCRIPT -echo "=> Deployed to $SSH_HOST" -echo "=> Visit $URL" +b=$'\033[1m' d=$'\033[2m' g=$'\033[32m' c=$'\033[36m' r=$'\033[0m' + echo "" -echo " Install the CLI on your local machine:" -echo " curl -fsSL $URL/install | bash" +echo " ${b}${g}🐾 Deployed${r} to ${b}$SSH_HOST${r}" +echo " ${d}─────────────────────────────${r}" +echo "" +echo " Dashboard: ${c}$URL${r}" +echo "" +echo " ${d}Grab the CLI:${r}" +echo " ${c}curl -fsSL $URL/install | bash${r}" echo "" diff --git a/src/server/install.sh b/src/server/install.sh index e33241a..b513cf2 100644 --- a/src/server/install.sh +++ b/src/server/install.sh @@ -1,19 +1,21 @@ #!/usr/bin/env bash set -e +b=$'\033[1m' d=$'\033[2m' g=$'\033[32m' c=$'\033[36m' y=$'\033[33m' r=$'\033[0m' + OS=$(uname -s | tr '[:upper:]' '[:lower:]') ARCH=$(uname -m) case "$OS" in darwin) OS=macos ;; linux) OS=linux ;; - *) echo "🐾 Unsupported OS: $OS" >&2; exit 1 ;; + *) echo "${y}Unsupported OS: $OS${r}" >&2; exit 1 ;; esac case "$ARCH" in x86_64) ARCH=x64 ;; arm64|aarch64) ARCH=arm64 ;; - *) echo "🐾 Unsupported arch: $ARCH" >&2; exit 1 ;; + *) echo "${y}Unsupported arch: $ARCH${r}" >&2; exit 1 ;; esac BINARY="toes-${OS}-${ARCH}" @@ -28,11 +30,18 @@ else fi mkdir -p "$INSTALL_DIR" -echo "🐾 Downloading toes CLI (${OS}/${ARCH})..." +echo "" +echo " ${b}🐾 toes cli${r}" +echo " ${d}─────────────────────────────${r}" +echo "" +echo " ${d}Fetching ${OS}/${ARCH}...${r}" curl -fsSL "$URL" -o "$INSTALL_DIR/toes" chmod +x "$INSTALL_DIR/toes" -echo "🐾 Installed toes to $INSTALL_DIR/toes" +echo " ${g}Installed to${r} ${b}$INSTALL_DIR/toes${r}" +echo "" if ! echo "$PATH" | tr ':' '\n' | grep -qx "$INSTALL_DIR"; then - echo "🐾 Add $INSTALL_DIR to your PATH to use toes globally" + echo " ${y}Add $INSTALL_DIR to your \$PATH, then:${r}" fi +echo " Run ${c}toes${r} to get started." +echo ""