Created
April 29, 2026 16:43
-
-
Save frarredondo/7a7b30b21e96c15e58bb111f38e5b622 to your computer and use it in GitHub Desktop.
tmux macOS setup — TPM + Dracula theme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env zsh | |
| # ============================================================ | |
| # tmux setup script for macOS | |
| # Installs: Homebrew, tmux, TPM, Dracula theme + plugins | |
| # ============================================================ | |
| set -e | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| CYAN='\033[0;36m' | |
| RESET='\033[0m' | |
| log() { echo "${GREEN}✔ $1${RESET}" } | |
| info() { echo "${CYAN}→ $1${RESET}" } | |
| warn() { echo "${YELLOW}⚠ $1${RESET}" } | |
| # ------------------------------------------------------------ | |
| # 1. Homebrew | |
| # ------------------------------------------------------------ | |
| info "Checking for Homebrew..." | |
| if ! command -v brew &>/dev/null; then | |
| warn "Homebrew not found. Installing..." | |
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
| # Add Homebrew to PATH for Apple Silicon Macs | |
| if [[ -f /opt/homebrew/bin/brew ]]; then | |
| eval "$(/opt/homebrew/bin/brew shellenv)" | |
| fi | |
| log "Homebrew installed." | |
| else | |
| log "Homebrew already installed." | |
| fi | |
| # ------------------------------------------------------------ | |
| # 2. tmux | |
| # ------------------------------------------------------------ | |
| info "Checking for tmux..." | |
| if ! command -v tmux &>/dev/null; then | |
| brew install tmux | |
| log "tmux installed." | |
| else | |
| log "tmux already installed: $(tmux -V)" | |
| fi | |
| # ------------------------------------------------------------ | |
| # 3. GitHub CLI (gh) — needed for Gist upload at the end | |
| # ------------------------------------------------------------ | |
| info "Checking for GitHub CLI (gh)..." | |
| if ! command -v gh &>/dev/null; then | |
| brew install gh | |
| log "GitHub CLI installed." | |
| else | |
| log "GitHub CLI already installed: $(gh --version | head -1)" | |
| fi | |
| # ------------------------------------------------------------ | |
| # 4. TPM (Tmux Plugin Manager) | |
| # ------------------------------------------------------------ | |
| TPM_DIR="$HOME/.tmux/plugins/tpm" | |
| info "Checking for TPM..." | |
| if [[ ! -d "$TPM_DIR" ]]; then | |
| git clone https://github.com/tmux-plugins/tpm "$TPM_DIR" | |
| log "TPM cloned to $TPM_DIR" | |
| else | |
| log "TPM already exists at $TPM_DIR" | |
| fi | |
| # ------------------------------------------------------------ | |
| # 5. Write ~/.tmux.conf | |
| # ------------------------------------------------------------ | |
| TMUX_CONF="$HOME/.tmux.conf" | |
| info "Writing $TMUX_CONF..." | |
| if [[ -f "$TMUX_CONF" ]]; then | |
| cp "$TMUX_CONF" "${TMUX_CONF}.bak.$(date +%Y%m%d%H%M%S)" | |
| warn "Existing ~/.tmux.conf backed up." | |
| fi | |
| cat > "$TMUX_CONF" << 'TMUXCONF' | |
| # ============================================================ | |
| # ~/.tmux.conf — macOS starter config with Dracula theme | |
| # ============================================================ | |
| # Remap prefix: Ctrl+b → Ctrl+a | |
| unbind C-b | |
| set-option -g prefix C-a | |
| bind-key C-a send-prefix | |
| # Enable mouse support (scroll, click panes/windows) | |
| set -g mouse on | |
| # Start window and pane numbering at 1 | |
| set -g base-index 1 | |
| set -g pane-base-index 1 | |
| set-window-option -g pane-base-index 1 | |
| set-option -g renumber-windows on | |
| # Increase scrollback buffer | |
| set -g history-limit 10000 | |
| # Use vi keys in copy mode | |
| set-window-option -g mode-keys vi | |
| bind-key -T copy-mode-vi v send-keys -X begin-selection | |
| bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel | |
| # Split panes with | and - (and keep current path) | |
| bind | split-window -h -c "#{pane_current_path}" | |
| bind - split-window -v -c "#{pane_current_path}" | |
| unbind '"' | |
| unbind % | |
| # Reload config with prefix + r | |
| bind r source-file ~/.tmux.conf \; display-message "Config reloaded!" | |
| # Faster key response | |
| set -s escape-time 0 | |
| set -g repeat-time 300 | |
| # True color support | |
| set -g default-terminal "tmux-256color" | |
| set -ag terminal-overrides ",xterm-256color:RGB" | |
| # ── Plugins ──────────────────────────────────────────────── | |
| set -g @plugin 'tmux-plugins/tpm' | |
| set -g @plugin 'tmux-plugins/tmux-sensible' # Sane defaults | |
| set -g @plugin 'tmux-plugins/tmux-yank' # Copy to macOS clipboard | |
| set -g @plugin 'tmux-plugins/tmux-resurrect' # Save/restore sessions | |
| set -g @plugin 'tmux-plugins/tmux-continuum' # Auto-save sessions | |
| set -g @plugin 'tmux-plugins/tmux-pain-control' # Standardized pane nav | |
| set -g @plugin 'dracula/tmux' # Dracula theme | |
| # ── Dracula theme config ─────────────────────────────────── | |
| set -g @dracula-plugins "cpu-usage ram-usage time" | |
| set -g @dracula-show-powerline true | |
| set -g @dracula-show-left-icon session | |
| set -g @dracula-show-flags true | |
| set -g @dracula-military-time true | |
| set -g @dracula-refresh-rate 5 | |
| set -g @dracula-cpu-usage-label "CPU" | |
| set -g @dracula-ram-usage-label "RAM" | |
| # ── tmux-resurrect options ───────────────────────────────── | |
| # Restore Neovim sessions too (requires a Session.vim file) | |
| set -g @resurrect-strategy-nvim 'session' | |
| # ── tmux-continuum options ───────────────────────────────── | |
| set -g @continuum-restore 'on' | |
| set -g @continuum-save-interval '15' | |
| # ── Initialize TPM (MUST be last line) ───────────────────── | |
| run '~/.tmux/plugins/tpm/tpm' | |
| TMUXCONF | |
| log "~/.tmux.conf written." | |
| # ------------------------------------------------------------ | |
| # 6. Install plugins headlessly via TPM | |
| # ------------------------------------------------------------ | |
| info "Installing tmux plugins via TPM (including Dracula)..." | |
| tmux new-session -d -s __setup__ 2>/dev/null || true | |
| tmux send-keys -t __setup__ "~/.tmux/plugins/tpm/bin/install_plugins" Enter | |
| sleep 8 | |
| tmux kill-session -t __setup__ 2>/dev/null || true | |
| log "Plugins installed." | |
| # ------------------------------------------------------------ | |
| # Done | |
| # ------------------------------------------------------------ | |
| echo "" | |
| echo "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}" | |
| echo "${GREEN} tmux setup complete!${RESET}" | |
| echo "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}" | |
| echo "" | |
| echo " Start tmux: ${CYAN}tmux${RESET}" | |
| echo " Reload config: ${CYAN}prefix + r${RESET} (Ctrl+a, then r)" | |
| echo " Install new plugins: ${CYAN}prefix + I${RESET} (capital I)" | |
| echo " Update plugins: ${CYAN}prefix + U${RESET}" | |
| echo " Save session: ${CYAN}prefix + Ctrl+s${RESET}" | |
| echo " Restore session: ${CYAN}prefix + Ctrl+r${RESET}" | |
| echo "" | |
| echo " Dracula status bar shows: CPU · RAM · Time" | |
| echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment