Created
May 10, 2026 23:56
-
-
Save cristiandley/182bd5c2c3d1e1fda9ae043926ccbd77 to your computer and use it in GitHub Desktop.
TMUX Setup
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 bash | |
| set -euo pipefail | |
| TMUX_CONF="$HOME/.tmux.conf" | |
| BACKUP="$HOME/.tmux.conf.backup.$(date +%Y%m%d-%H%M%S)" | |
| echo "Setting up custom tmux config..." | |
| if [ -f "$TMUX_CONF" ]; then | |
| echo "Existing ~/.tmux.conf found. Creating backup:" | |
| echo "$BACKUP" | |
| cp "$TMUX_CONF" "$BACKUP" | |
| fi | |
| cat > "$TMUX_CONF" <<'EOF' | |
| # Prefix: Ctrl+a instead of Ctrl+b | |
| unbind C-b | |
| set -g prefix C-a | |
| bind C-a send-prefix | |
| # Better pane splitting | |
| bind | split-window -h | |
| bind - split-window -v | |
| unbind '"' | |
| unbind % | |
| # Vim-like pane movement | |
| bind h select-pane -L | |
| bind j select-pane -D | |
| bind k select-pane -U | |
| bind l select-pane -R | |
| # Resize panes with capital H/J/K/L | |
| bind H resize-pane -L 5 | |
| bind J resize-pane -D 5 | |
| bind K resize-pane -U 5 | |
| bind L resize-pane -R 5 | |
| # Mouse support | |
| set -g mouse on | |
| # Start windows and panes at 1 | |
| set -g base-index 1 | |
| setw -g pane-base-index 1 | |
| # Better colors | |
| set -g default-terminal "tmux-256color" | |
| set -ga terminal-overrides ",xterm-256color:RGB" | |
| # Easier config reload | |
| bind r source-file ~/.tmux.conf \; display-message "tmux config reloaded" | |
| # Status bar | |
| set -g status-position bottom | |
| set -g status-interval 5 | |
| set -g status-left-length 40 | |
| set -g status-right-length 80 | |
| # History | |
| set -g history-limit 50000 | |
| # Renumber windows after closing one | |
| set -g renumber-windows on | |
| # Escape delay: makes Vim/Neovim feel faster | |
| set -sg escape-time 10 | |
| EOF | |
| echo "tmux config written to $TMUX_CONF" | |
| if command -v tmux >/dev/null 2>&1; then | |
| if tmux has-session 2>/dev/null; then | |
| tmux source-file "$TMUX_CONF" | |
| echo "Reloaded config in current tmux server." | |
| else | |
| echo "No active tmux session found." | |
| fi | |
| else | |
| echo "tmux is not installed. Install it with:" | |
| echo "brew install tmux" | |
| fi | |
| echo "Done." | |
| echo "" | |
| echo "Main shortcuts:" | |
| echo " Ctrl+a then | split vertical" | |
| echo " Ctrl+a then - split horizontal" | |
| echo " Ctrl+a then h/j/k/l move panes" | |
| echo " Ctrl+a then H/J/K/L resize panes" | |
| echo " Ctrl+a then c new window" | |
| echo " Ctrl+a then d detach" | |
| echo " Ctrl+a then r reload config" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment