Using Tmux for Software Development

I first found about tmux some years ago, when I was trying to make neovim work for me as a text editor for my software development, I realized that working on the terminal to do my work as a SDET (Software Development Engineer in Test) was super fun, so I watched a lot of videos on how to setup and even bought a book about Tmux 2 by Brian P. Hogan, I was facinated by the level of details and cool stuff that you can accomplish with Tmux, how you can be more productive, but at the end of the day how you can enjoy more developing on the terminal, I wanted to share with you my tmux setup.
This blog post is super short because I just wanted to share my tmux configuration.
# Setting default shell
set -g default-shell /bin/zsh
# Set the default
set -g default-terminal "tmux-256color"
set-option -ga terminal-overrides ",xterm-256color:Tc"
#Setting the prefix from C-b to C-a
set -g prefix C-a
# Free the original Ctrl-b prefix keybinding
unbind C-b
# Setting the delay between prefix and command
set -s escape-time 0
# Set the base index for windows to 1 instead of 0
set -g base-index 1
# Set the base index for panes to 1 instead of 0
setw -g pane-base-index 1
# Reloads the configuration file with the binding r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# Ensure that we can send Ctrl-A to other apps, by pressing Ctrl-a twice
bind C-a send-prefix
# Splitting panes with L and -
bind i split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# Open a new bottom terminal pane (20% height)
bind t split-window -v -p 20 -c "#{pane_current_path}"
# Moving between panes with prefix h,j,k,l
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Quick window selection
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# Resizing panes with VIM Bindings
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# Setting mouse support
set -g mouse on
# Setting Status line colors
set -g status-style fg=white,bold,bg=black
# Set the color of the window list
setw -g window-status-style fg=cyan,bg=black
# Set colors for the active window
setw -g window-status-current-style fg=white,bold,bg=red
# Colors for pane borders
set -g pane-border-style fg=colour19,bg=colour0
set -g pane-active-border-style bg=colour0,fg=colour9
# Active pane normal, other shaded out
#setw -g window-style fg=colour240,bg=colour235
#setw -g window-active-style fg=white,bg=black
# Command / message line
set -g message-style fg=white,bold,bg=black
# Status line left side to show Session:window:pane
set -g status-left-length 40
set -g status-left "#[fg=green]Session:#S #[fg=yello]#I #[fg=cyan]#P "
# Status line right side - 24-Feb 13:17
set -g status-right "#[fg=cyan]%d %b %R"
# Update the status line every 15 seconds
set -g status-interval 15
# focus events for neovim auto-reload
set-option -g focus-events on
# Enable activity alerts
setw -g monitor-activity on
set -g visual-activity on
# Automatically create a bottom terminal pane on new session
set-hook -g after-new-session 'split-window -v -p 20 -c "#{pane_current_path}"'
# Enable vi keys
setw -g mode-keys vi
# Binding to VIM for Copy and Paste
bind Escape copy-mode
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi y send -X copy-selection
unbind p
bind p paste-buffer
# Binding to switch between sessions
bind ( switch-client -p
bind ) switch-client -n
# Load mac-specific settings
#if-shell "uname | grep -q Darwin" "source-file ~/.dotfiles/tmux.mac.conf"
# Prefix Ctrl-c takes what's in the buffer and sends it to the system clipboard
# via xclip
bind C-c run "tmux save-buffer - / xclip -sel clip -i"
# y in copy mode takes selection and sends it to the system clipboard via xclip
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -sel clip -i"
# Prefix Ctrl-v fills tmux buffer from system clipboard via xclip, then
# pastes from buffer into tmux window
bind C-v run "tmux set-buffer \"$(xclip -sel clip -o)\"; tmux paste-buffer"
# Log output to a text file on demand
bind P pipe-pane -o "cat >>~/#W.log" \; display "Toggled logging to ~/#W.log"
# Status line right side - 50% | 24 Feb 13:33
set -g status-right "#(~/.dotfiles/battery Discharging) | #[fg=cyan]%d %b %R"
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-=' select-pane -l
# Setting TPM Tmux Plugin Manager
# ============================================================================
# TPM Installation & Plugin Management Instructions:
# ============================================================================
# 1. INSTALL TPM (if not already installed):
# git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
#
# 2. RELOAD tmux config:
# tmux source ~/.tmux.conf
# OR press: prefix + r (Ctrl-a + r)
#
# 3. INSTALL PLUGINS:
# Press: prefix + I (Ctrl-a + Shift-i)
# Wait for "TMUX environment reloaded" message
#
# 4. UPDATE PLUGINS:
# Press: prefix + U (Ctrl-a + Shift-u)
#
# 5. UNINSTALL PLUGINS (after removing from list below):
# Press: prefix + alt + u
#
# 6. TROUBLESHOOTING:
# - If you get "'~/.tmux/plugins/tpm/tpm' returned 127" error:
# TPM is not installed. Run step 1 above.
# - If plugins don't work after install:
# Kill all tmux sessions and start fresh: tmux kill-server
# ============================================================================
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-yank'
# ============================================================================
# Plugin Configuration
# ============================================================================
# tmux-resurrect settings
# Restore additional programs
set -g @resurrect-processes 'ssh psql mysql sqlite3'
# Capture pane contents
set -g @resurrect-capture-pane-contents 'on'
# Restore nvim sessions (requires tpope/vim-obsession or similar)
set -g @resurrect-strategy-nvim 'session'
# tmux-continuum settings
# Auto-save tmux environment every 15 minutes
set -g @continuum-save-interval '15'
# Auto-restore tmux sessions on tmux start
set -g @continuum-restore 'on'
# Show continuum status in status bar (optional)
# set -g status-right 'Continuum: #{continuum_status} | %a %h-%d %H:%M'
# tmux-yank settings
# Use OSC52 for remote clipboard (works over SSH)
set -g @yank_selection 'clipboard'
set -g @yank_selection_mouse 'clipboard'
# Use OSC52 when SSH session detected
set -g @override_copy_command 'true'
# Custom copy command that uses OSC52
set -g @custom_copy_command 'printf "\033]52;c;$(base64 | tr -d "\n")\a"'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'