-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·184 lines (155 loc) · 7.27 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·184 lines (155 loc) · 7.27 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/usr/bin/env bash
# install.sh - Chadmacs one-line installer.
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/Borderliner/Chadmacs/master/install.sh | bash
#
# Or from a local checkout:
# bash install.sh
#
# What it does:
# 1. Backs up an existing ~/.emacs.d to ~/.emacs.d.backup-YYYYMMDD-HHMMSS
# 2. Clones Borderliner/Chadmacs into ~/.emacs.d
# 3. Adds ~/.emacs.d/bin to PATH in bash / zsh / fish rc files (idempotent)
# 4. Prints next steps.
set -euo pipefail
CHADMACS_REPO="${CHADMACS_REPO:-git@github.com:Borderliner/Chadmacs.git}"
CHADMACS_BRANCH="${CHADMACS_BRANCH:-master}"
CHADMACS_DIR="${CHADMACS_DIR:-$HOME/.emacs.d}"
# ---- colors -----------------------------------------------------------------
if [ -t 1 ] && command -v tput >/dev/null 2>&1 && [ "$(tput colors 2>/dev/null || echo 0)" -ge 8 ]; then
C_RESET="$(tput sgr0)"
C_BOLD="$(tput bold)"
C_GREEN="$(tput setaf 2)"
C_YELLOW="$(tput setaf 3)"
C_RED="$(tput setaf 1)"
C_BLUE="$(tput setaf 4)"
else
C_RESET= C_BOLD= C_GREEN= C_YELLOW= C_RED= C_BLUE=
fi
say() { printf '%s•%s %s\n' "$C_BLUE" "$C_RESET" "$*"; }
ok() { printf '%s✓%s %s\n' "$C_GREEN" "$C_RESET" "$*"; }
warn() { printf '%s!%s %s\n' "$C_YELLOW" "$C_RESET" "$*"; }
die() { printf '%s✗%s %s\n' "$C_RED" "$C_RESET" "$*" >&2; exit 1; }
hdr() { printf '\n%s%s%s\n' "$C_BOLD" "$*" "$C_RESET"; }
have() { command -v "$1" >/dev/null 2>&1; }
# ---- preflight --------------------------------------------------------------
have git || die "git is required. Install git and re-run."
# ---- header -----------------------------------------------------------------
cat <<'BANNER'
▄████████ ▄█ █▄ ▄████████ ████████▄ ▄▄▄▄███▄▄▄▄ ▄████████ ▄████████ ▄████████
███ ███ ███ ███ ███ ███ ███ ▀███ ▄██▀▀▀███▀▀▀██▄ ███ ███ ███ ███ ███ ███
███ █▀ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ █▀ ███ █▀
███ ▄███▄▄▄▄███▄▄ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
███ ▀▀███▀▀▀▀███▀ ▀███████████ ███ ███ ███ ███ ███ ▀███████████ ███ ▀███████████
███ █▄ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ █▄ ███
███ ███ ███ ███ ███ ███ ███ ▄███ ███ ███ ███ ███ ███ ███ ███ ▄█ ███
████████▀ ███ █▀ ███ █▀ ████████▀ ▀█ ███ █▀ ███ █▀ ████████▀ ▄████████▀
Ultra-clean, ultra-fast Emacs config.
BANNER
# ---- backup existing --------------------------------------------------------
if [ -e "$CHADMACS_DIR" ]; then
BACKUP_DIR="${CHADMACS_DIR}.backup-$(date +%Y%m%d-%H%M%S)"
hdr "Backing up existing $CHADMACS_DIR"
mv "$CHADMACS_DIR" "$BACKUP_DIR"
ok "Moved to $BACKUP_DIR"
fi
# ---- clone ------------------------------------------------------------------
hdr "Cloning Chadmacs"
say "git clone --depth=1 -b $CHADMACS_BRANCH $CHADMACS_REPO -> $CHADMACS_DIR"
git clone --depth=1 -b "$CHADMACS_BRANCH" "$CHADMACS_REPO" "$CHADMACS_DIR"
ok "Cloned."
# ---- chmod bin --------------------------------------------------------------
if [ -f "$CHADMACS_DIR/bin/chadmacs" ]; then
chmod +x "$CHADMACS_DIR/bin/chadmacs"
ok "Made $CHADMACS_DIR/bin/chadmacs executable."
fi
# ---- shell PATH wiring ------------------------------------------------------
hdr "Wiring \$PATH for shells"
BIN_DIR="$CHADMACS_DIR/bin"
MARKER="# >>> chadmacs PATH >>>"
MARKER_END="# <<< chadmacs PATH <<<"
# bash
wire_bash_zsh() {
local rc="$1"
if [ -f "$rc" ] && grep -q "$MARKER" "$rc"; then
ok "$rc already wired."
return
fi
cat >>"$rc" <<EOF
$MARKER
export PATH="$BIN_DIR:\$PATH"
$MARKER_END
EOF
ok "Appended PATH export to $rc"
}
# bash + zsh share the same form
if [ -f "$HOME/.bashrc" ] || have bash; then wire_bash_zsh "$HOME/.bashrc"; fi
if [ -f "$HOME/.bash_profile" ] && ! grep -q "$MARKER" "$HOME/.bash_profile" 2>/dev/null; then
wire_bash_zsh "$HOME/.bash_profile"
fi
if [ -f "$HOME/.zshrc" ] || have zsh; then wire_bash_zsh "$HOME/.zshrc"; fi
# fish (different syntax + fish_add_path is preferred)
if have fish; then
FISH_CONF="$HOME/.config/fish/conf.d"
mkdir -p "$FISH_CONF"
FISH_FILE="$FISH_CONF/chadmacs.fish"
if [ -f "$FISH_FILE" ]; then
ok "$FISH_FILE already present."
else
cat >"$FISH_FILE" <<EOF
# Chadmacs PATH wiring
if test -d "$BIN_DIR"
fish_add_path -gP "$BIN_DIR"
end
EOF
ok "Created $FISH_FILE"
fi
fi
# ---- fd / fdfind shim (Debian / Ubuntu) -------------------------------------
# fd ships as 'fdfind' on apt-based distros to avoid colliding with the
# unrelated `fd' chess move tool. Upstream README recommends the same
# symlink we create here. Skipped silently if fd is already present.
if ! have fd && have fdfind; then
hdr "Linking fdfind as fd"
mkdir -p "$HOME/.local/bin"
ln -sf "$(command -v fdfind)" "$HOME/.local/bin/fd"
ok "Symlinked $HOME/.local/bin/fd -> $(command -v fdfind)"
case ":$PATH:" in
*":$HOME/.local/bin:"*) ;;
*) warn "Add $HOME/.local/bin to \$PATH (re-open your shell or fix in rc files)." ;;
esac
fi
# ---- preflight inside emacs -------------------------------------------------
hdr "Smoke test"
if have emacs; then
EV=$(emacs --batch --eval '(princ emacs-version)' 2>/dev/null || echo "?")
MAJOR=$(printf '%s' "$EV" | cut -d. -f1)
if [ "$MAJOR" -ge 29 ] 2>/dev/null; then
ok "Emacs $EV detected — meets the 29+ requirement."
else
warn "Emacs $EV is older than 29 — install a newer Emacs before launching Chadmacs."
fi
else
warn "Emacs not installed. Install it before launching Chadmacs."
fi
# ---- next steps -------------------------------------------------------------
hdr "Done"
cat <<EOF
${C_BOLD}Next steps${C_RESET}
1. Open a new shell (or source your rc) so the chadmacs CLI is on \$PATH:
${C_BLUE}exec \$SHELL${C_RESET}
2. Run the doctor to see what's installed:
${C_BLUE}chadmacs doctor${C_RESET}
3. Launch Emacs. Elpaca will bootstrap and build every package on
first run (a few minutes). Watch ${C_BLUE}*elpaca-log*${C_RESET} in Emacs.
${C_BLUE}emacs${C_RESET}
4. Enable the languages you use by editing:
${C_BLUE}~/.emacs.d/custom.el${C_RESET}
(Auto-generated on first launch, gitignored — safe from updates.)
5. Updating:
${C_BLUE}chadmacs update${C_RESET}
6. Removing:
${C_BLUE}chadmacs uninstall${C_RESET} (your var/ will be backed up)
Enjoy your editor. 🗿🔥
EOF