Skip to content

Instantly share code, notes, and snippets.

@reissbaker
Last active November 7, 2023 08:13
Show Gist options
  • Save reissbaker/8f8b154abc1a2ae2cbda820c6d4a32da to your computer and use it in GitHub Desktop.
Save reissbaker/8f8b154abc1a2ae2cbda820c6d4a32da to your computer and use it in GitHub Desktop.

Window Controls

  • ⌘ ← 0x02 0x70
  • ⌘ → 0x02 0x6E

Pane Controls

  • ⌘ ⌥ ↑ 0x02 0x1B 0x5B 0x41
  • ⌘ ⌥ ↓ 0x02 0x1B 0x5B 0x42
  • ⌘ ⌥ → 0x02 0x1B 0x5B 0x43
  • ⌘ ⌥ ← 0x02 0x1B 0x5B 0x44
# For Mac OS, use reattach-to-user-namespace to get native copy/paste back and
# to set the default shell to zsh
set-option -g default-command 'reattach-to-user-namespace -l zsh'
# Smart pane switching with awareness of vim splits
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
# General
# ------------------------------------------------------------------------------
# Increase default history scrollback (default is 2000)
set-option -g history-limit 5000
# Native Integration
# ------------------------------------------------------------------------------
# Ensure colors are up to snuff
set -g default-terminal 'screen-256color'
# Native mouse window manipulation
set -g mouse on
# Actually scroll the window when the mouse is scrolled
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
# Vi keybindings for leader-key movement
set -g status-keys vi
set-window-option -g mode-keys vi
setw -g mode-keys vi
# Allow hex codes to be sent from iTerm2
set -g assume-paste-time 0
# Send focus events (useful for Vim plugins)
set -g focus-events on
# Allow special cursor change codes through
set -g -a terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q'
# Faster escape time for CLIs
set -sg escape-time 10
# Status Line
# ------------------------------------------------------------------------------
# Make the base index 1
set-option -g base-index 1
# Make the pane base index be 1 as well
setw -g pane-base-index 1
# Put status bar on top
set-option -g status-position top
# Key Bindings
# ------------------------------------------------------------------------------
# Force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
# Window splitting
unbind %
unbind V
unbind H
unbind k
bind V split-window -h -c "#{pane_current_path}"
bind H split-window -v -c "#{pane_current_path}"
bind k kill-pane -a
# Pane manipulation shouldn't repeat
bind-key Up select-pane -U
bind-key Down select-pane -D
bind-key Left select-pane -L
bind-key Right select-pane -R
# New tabs should start in current directory
bind c new-window -c "#{pane_current_path}"
# Colors
# ------------------------------------------------------------------------------
# Set status bar
set -g status-bg colour235
set -g status-fg colour246
set-window-option -g window-status-current-fg colour254
set-window-option -g window-status-current-bg colour234
# Set tab format
setw -g window-status-format " #I:#W "
setw -g window-status-current-format " #I:#W "
# Remove session info
set -g status-left ''
# Window
set -g window-style 'fg=colour247,bg=colour233'
set -g window-active-style 'fg=colour247,bg=colour234'
# Pane border
set-option -g pane-border-bg colour235
set-option -g pane-border-fg colour235
set-option -g pane-active-border-bg colour235
set-option -g pane-active-border-fg colour235
# Set color when status bar needs input
set-option -g message-bg colour232
set-option -g message-fg colour254
# Source OS-specific conf files
# ------------------------------------------------------------------------------
if-shell "uname | grep -q Darwin" "source ~/dotfiles/tmux-macos.conf" "source ~/dotfiles/tmux-linux.conf"
@reilg
Copy link

reilg commented Nov 7, 2023

Hi, how exactly do you map the command key to work like that? I'd like to map command + hjkl to pane navigation but I don't see how you set it up on this config. That or I don't understand how you did it.

Is it this command? set-option -g default-command 'reattach-to-user-namespace -l zsh'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment