|
#!/bin/bash |
|
# Ghostty + Zsh Enhancement Setup |
|
# Run: curl -fsSL <raw-gist-url>/setup.sh | bash |
|
# Or: git clone <gist-url> dotfiles && cd dotfiles && ./setup.sh |
|
|
|
set -e |
|
|
|
echo "🚀 Setting up Ghostty terminal enhancements..." |
|
|
|
# ── Step 1: Check prerequisites ───────────────────────────────────────────── |
|
if [[ "$SHELL" != */zsh ]]; then |
|
echo "❌ Please switch to zsh first: chsh -s /bin/zsh" |
|
exit 1 |
|
fi |
|
|
|
if ! command -v brew &>/dev/null; then |
|
echo "❌ Homebrew not found. Install from https://brew.sh" |
|
exit 1 |
|
fi |
|
|
|
# ── Step 2: Install tools ─────────────────────────────────────────────────── |
|
echo "📦 Installing tools via Homebrew..." |
|
brew install fzf zoxide antidote |
|
brew install --cask font-meslo-lg-nerd-font |
|
|
|
# ── Step 3: Backup existing config ────────────────────────────────────────── |
|
if [[ -f ~/.zshrc ]]; then |
|
BACKUP=~/.zshrc.backup.$(date +%Y%m%d-%H%M%S) |
|
cp ~/.zshrc "$BACKUP" |
|
echo "📁 Backed up existing .zshrc to $BACKUP" |
|
fi |
|
|
|
# ── Step 4: Get script directory (works for both clone and curl) ──────────── |
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
|
|
|
# ── Step 5: Install dotfiles ──────────────────────────────────────────────── |
|
echo "📝 Installing dotfiles..." |
|
|
|
# Copy files from gist/repo |
|
cp "$SCRIPT_DIR/zshrc" ~/.zshrc |
|
cp "$SCRIPT_DIR/zsh_plugins.txt" ~/.zsh_plugins.txt |
|
|
|
# Create .zshrc.pre if it doesn't exist (machine-specific config goes here) |
|
if [[ ! -f ~/.zshrc.pre ]]; then |
|
cp "$SCRIPT_DIR/zshrc.pre.template" ~/.zshrc.pre |
|
echo "📝 Created ~/.zshrc.pre - edit this for machine-specific settings" |
|
fi |
|
|
|
# Copy p10k config if included |
|
if [[ -f "$SCRIPT_DIR/p10k.zsh" ]]; then |
|
cp "$SCRIPT_DIR/p10k.zsh" ~/.p10k.zsh |
|
fi |
|
|
|
# ── Step 6: Setup Ghostty config ──────────────────────────────────────────── |
|
GHOSTTY_DIR="$HOME/Library/Application Support/com.mitchellh.ghostty" |
|
if [[ -d "$GHOSTTY_DIR" ]]; then |
|
if [[ -f "$GHOSTTY_DIR/config" ]]; then |
|
# Update font in existing config |
|
if grep -q "font-family" "$GHOSTTY_DIR/config"; then |
|
sed -i '' 's/font-family = .*/font-family = "MesloLGS Nerd Font"/' "$GHOSTTY_DIR/config" |
|
else |
|
echo 'font-family = "MesloLGS Nerd Font"' >> "$GHOSTTY_DIR/config" |
|
fi |
|
else |
|
cp "$SCRIPT_DIR/ghostty.config" "$GHOSTTY_DIR/config" |
|
fi |
|
echo "👻 Ghostty config updated" |
|
fi |
|
|
|
# ── Step 7: Initialize plugins ────────────────────────────────────────────── |
|
echo "🔌 Initializing plugins (this may take a moment)..." |
|
zsh -c 'source ~/.zshrc' 2>/dev/null || true |
|
|
|
# ── Done! ─────────────────────────────────────────────────────────────────── |
|
echo "" |
|
echo "✅ Setup complete!" |
|
echo "" |
|
echo "Next steps:" |
|
echo " 1. Quit and reopen Ghostty (to load the new font)" |
|
echo " 2. Run 'p10k configure' if prompt wizard doesn't start automatically" |
|
echo " 3. Edit ~/.zshrc.pre for machine-specific paths/aliases" |
|
echo "" |