-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshellraiser.sh
More file actions
executable file
·83 lines (71 loc) · 2.91 KB
/
shellraiser.sh
File metadata and controls
executable file
·83 lines (71 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# ╔══════════════════════════════════════════════╗
# ║ shellraiser — theme switcher ║
# ╚══════════════════════════════════════════════╝
# Usage: shellraiser [theme-name]
# Switch themes without reinstalling.
set -e
SR_DIR="$(cd "$(dirname "$0")" && pwd)"
THEME_NAME="${1:-}"
ZSHRC="$HOME/.zshrc"
G=$'\033[38;2;51;255;0m'
Y=$'\033[38;2;255;225;0m'
R=$'\033[38;2;255;0;68m'
D=$'\033[38;2;68;68;68m'
C=$'\033[38;2;0;255;204m'
P=$'\033[38;2;255;113;206m'
B=$'\033[1m'
X=$'\033[0m'
fail() { echo " ${R}✗ $1${X}"; exit 1; }
ok() { echo " ${G}✓${X} ${D}$1${X}"; }
# ── No args: show current theme + available themes ──
if [[ -z "$THEME_NAME" ]]; then
CURRENT=$(grep 'SHELLRAISER_THEME=' "$ZSHRC" 2>/dev/null | head -1 | sed 's/.*SHELLRAISER_THEME="//' | sed 's/".*//' || echo "none")
echo ""
echo " ${Y}${B}s h e l l r a i s e r${X}"
echo ""
echo " ${D}current:${X} ${G}${CURRENT}${X}"
echo ""
echo " ${D}available themes:${X}"
echo " ${Y}1up${X} ${D}retro arcade${X}"
echo " ${Y}muji${X} ${D}minimalist${X}"
echo " ${C}neon${X} ${D}cyberpunk${X}"
echo " ${P}shibuya${X} ${D}vaporwave${X}"
echo " ${R}pinhead${X} ${D}horror${X}"
echo ""
echo " ${D}switch:${X} ${G}shellraiser <theme-name>${X}"
echo ""
exit 0
fi
# ── Validate theme ──
THEME_DIR="$SR_DIR/themes/$THEME_NAME"
[[ -d "$THEME_DIR" ]] || fail "Unknown theme: $THEME_NAME (check themes/ directory)"
[[ -f "$THEME_DIR/theme.zsh" ]] || fail "Theme '$THEME_NAME' is missing theme.zsh"
PROFILE_NAME=$(echo "$THEME_NAME" | tr '[:lower:]' '[:upper:]')
PROFILE_FILE="$THEME_DIR/${THEME_NAME}.terminal"
THEME_ZSH="$THEME_DIR/theme.zsh"
# ── Generate profile if needed ──
if [[ -f "$THEME_DIR/generate-profile.py" ]] && [[ ! -f "$PROFILE_FILE" ]]; then
if python3 -c "import AppKit" &>/dev/null; then
python3 "$THEME_DIR/generate-profile.py" "$THEME_DIR"
ok "Generated Terminal.app profile"
fi
fi
# ── Import and set Terminal.app profile ──
if [[ -f "$PROFILE_FILE" ]]; then
open "$PROFILE_FILE"
sleep 1
defaults write com.apple.Terminal "Default Window Settings" -string "$PROFILE_NAME"
defaults write com.apple.Terminal "Startup Window Settings" -string "$PROFILE_NAME"
ok "Set '$PROFILE_NAME' as Terminal.app default"
else
echo " ${Y}!${X} ${D}No .terminal profile found. Colors won't change until you regenerate.${X}"
fi
# ── Update .zshrc ──
source "$SR_DIR/lib/zshrc.sh"
shellraiser_remove_block "$ZSHRC"
shellraiser_write_block "$SR_DIR" "$THEME_NAME" "$THEME_ZSH" "$ZSHRC"
ok "Switched to ${THEME_NAME}"
echo ""
echo " ${D}Close and reopen Terminal, or run: ${G}source ~/.zshrc${X}"
echo ""