#!/bin/sh set -e REPO_URL="https://github.com/h80r/dotfiles" DOTFILES_DIR="$HOME/Code/dotfiles" # ── Colors ──────────────────────────────────────────────────────────────────── RESET='\033[0m' BOLD='\033[1m' GREEN='\033[0;32m' YELLOW='\033[0;33m' BLUE='\033[0;34m' RED='\033[0;31m' info() { printf "${BLUE} →${RESET} %s\n" "$1"; } success() { printf "${GREEN} ✓${RESET} %s\n" "$1"; } skip() { printf "${YELLOW} ⊘${RESET} %s (já instalado)\n" "$1"; } section() { printf "\n${BOLD}${BLUE}▶ %s${RESET}\n" "$1"; } error() { printf "${RED} ✗${RESET} %s\n" "$1" >&2; exit 1; } # ── Helpers ─────────────────────────────────────────────────────────────────── is_installed() { command -v "$1" > /dev/null 2>&1; } brew_installed() { brew list --formula 2>/dev/null | grep -q "^$1\$"; } cask_installed() { brew list --cask 2>/dev/null | grep -q "^$1\$"; } # ── 1. Homebrew ─────────────────────────────────────────────────────────────── section "Homebrew" if is_installed brew; then skip "brew" else info "instalando Homebrew..." /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" success "Homebrew instalado" fi # ── 2. Clone do repo de dotfiles ───────────────────────────────────────────── section "Dotfiles" if [ -d "$DOTFILES_DIR/.git" ]; then skip "repo já clonado em $DOTFILES_DIR" info "atualizando..." git -C "$DOTFILES_DIR" pull --ff-only else info "clonando $REPO_URL em $DOTFILES_DIR..." mkdir -p "$HOME/Code" git clone "$REPO_URL" "$DOTFILES_DIR" success "repo clonado" fi # ── 3. Claude Code ──────────────────────────────────────────────────────────── section "Claude Code" if is_installed claude; then skip "claude" else info "instalando Claude Code..." curl -fsSL https://claude.ai/install.sh | bash success "Claude Code instalado" fi # ── 4. Ghostty ──────────────────────────────────────────────────────────────── section "Ghostty" if cask_installed ghostty; then skip "ghostty" else info "instalando Ghostty..." brew install --cask ghostty success "Ghostty instalado" fi # ── 5. fzf ──────────────────────────────────────────────────────────────────── section "fzf" if brew_installed fzf; then skip "fzf" else info "instalando fzf..." brew install fzf success "fzf instalado" fi # ── 6. zoxide ───────────────────────────────────────────────────────────────── section "zoxide" if brew_installed zoxide; then skip "zoxide" else info "instalando zoxide..." brew install zoxide success "zoxide instalado" fi # ── 7. Fontes ───────────────────────────────────────────────────────────────── section "Fontes" if cask_installed font-geist-mono-nerd-font; then skip "font-geist-mono-nerd-font" else info "instalando GeistMono Nerd Font..." brew install --cask font-geist-mono-nerd-font success "GeistMono Nerd Font instalada" fi if brew_installed font-symbols-only-nerd-font; then skip "font-symbols-only-nerd-font" else info "instalando Symbols Only Nerd Font..." brew install font-symbols-only-nerd-font success "Symbols Only Nerd Font instalada" fi # ── 8. yazi ─────────────────────────────────────────────────────────────────── section "yazi" if brew_installed yazi; then skip "yazi" else info "instalando yazi..." brew install yazi success "yazi instalado" fi # ── 9. lazygit ──────────────────────────────────────────────────────────────── section "lazygit" if brew_installed lazygit; then skip "lazygit" else info "instalando lazygit..." brew install lazygit success "lazygit instalado" fi # ── 10. Fish shell ──────────────────────────────────────────────────────────── section "Fish shell" if brew_installed fish; then skip "fish" else info "instalando Fish..." brew install fish success "Fish instalado" fi FISH_PATH="$(brew --prefix)/bin/fish" if grep -qF "$FISH_PATH" /etc/shells 2>/dev/null; then skip "fish já está em /etc/shells" else info "adicionando fish ao /etc/shells..." echo "$FISH_PATH" | sudo tee -a /etc/shells > /dev/null success "fish adicionado ao /etc/shells" fi if [ "$SHELL" = "$FISH_PATH" ]; then skip "fish já é o shell padrão" else info "definindo fish como shell padrão..." chsh -s "$FISH_PATH" success "fish definido como shell padrão" fi # ── 11. Symlinks de configs ─────────────────────────────────────────────────── section "Configs (symlinks)" # fish FISH_CONFIG_DIR="$HOME/.config/fish" mkdir -p "$FISH_CONFIG_DIR" if [ -L "$FISH_CONFIG_DIR/config.fish" ]; then skip "~/.config/fish/config.fish" else ln -sf "$DOTFILES_DIR/.config/fish/config.fish" "$FISH_CONFIG_DIR/config.fish" success "~/.config/fish/config.fish → dotfiles" fi # gitconfig if [ -L "$HOME/.gitconfig" ]; then skip "~/.gitconfig" else ln -sf "$DOTFILES_DIR/.gitconfig" "$HOME/.gitconfig" success "~/.gitconfig → dotfiles" fi # ghostty GHOSTTY_CONFIG_DIR="$HOME/Library/Application Support/com.mitchellh.ghostty" mkdir -p "$GHOSTTY_CONFIG_DIR" if [ -L "$GHOSTTY_CONFIG_DIR/config" ]; then skip "ghostty config" else ln -sf "$DOTFILES_DIR/ghostty/config.ghostty" "$GHOSTTY_CONFIG_DIR/config" success "ghostty config → dotfiles" fi if [ -L "$GHOSTTY_CONFIG_DIR/dev-layout.applescript" ]; then skip "ghostty dev-layout.applescript" else ln -sf "$DOTFILES_DIR/ghostty/dev-layout.applescript" "$GHOSTTY_CONFIG_DIR/dev-layout.applescript" success "ghostty dev-layout.applescript → dotfiles" fi # ── 12. Wallpaper ───────────────────────────────────────────────────────────── sh "$DOTFILES_DIR/scripts/wallpaper.sh" # ── Fim ─────────────────────────────────────────────────────────────────────── printf "\n${BOLD}${GREEN}✓ Ambiente configurado com sucesso!${RESET}\n" printf "\n Reinicie o terminal para que todas as mudanças tenham efeito.\n\n"