Skip to content

Instantly share code, notes, and snippets.

@echelon
Last active May 12, 2023 06:07
Show Gist options
  • Save echelon/0679be63f2dddcb6ca6e921e8e6d8724 to your computer and use it in GitHub Desktop.
Save echelon/0679be63f2dddcb6ca6e921e8e6d8724 to your computer and use it in GitHub Desktop.
tmux.conf
# TODO(bt): reorganize, check into github
# Default configuration
# set -g utf8
# setw -g utf8 on
set -g default-terminal "screen-256color"
set -g history-limit 1000000 # Much history.
set -s escape-time 0 # Vim escape cannot be laggy!
set -g repeat-time 1000
# See https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
# set-option -g default-command "reattach-to-user-namespace -l bash"
# Untrain thyself of `prefix -> navigation -> repeat` loops.
unbind-key j
unbind-key k
unbind-key h
unbind-key l
# O and o are super annoying. Just use { and }
unbind-key o
unbind-key O
unbind-key ? # Unbind default list-keys
# Vim mode
# Check out the "vi-copy" key table with `:list-keys -t vi-copy`
setw -g mode-keys vi
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
bind-key p paste-buffer
# (Re-)Source the tmux.conf!
# The binding `s` was previously choose-tree
bind r source-file ~/.tmux.conf \; display "Reloaded tmux.conf!"
bind s source-file ~/.tmux.conf \; display "Reloaded tmux.conf!"
# Clear the scrollback buffer (Yay!)
# The binding `C-q` previously displayed the pane number (kind of useful...)
bind C-q send-keys -R \; clear-history \; display "clear-history"
bind -n C-q send-keys -R \; clear-history \; display "clear-history"
# Edit configuration
bind v new-window 'vi ~/.tmux.conf'
# For terminals that support mouse events
#set -g mode-mouse on
#set -g mouse-resize-pane on
#set -g mouse-select-pane on
#set -g mouse-select-window on
# Change help / list-keys
bind-key h list-keys
# Search Up and Down (instantly!)
bind-key / copy-mode \; send-keys /
bind-key ? copy-mode \; send-keys ?
# TODO: binding for choose-tree (also, what is 'choose-tree'?)
# TODO: vimrc idea. Swap j/k with ctrl-j/k. Each should be inverse!
#set -g status-keys emacs # With vi, must hit escape twice :(
#setw -g default-path "$PWD" # TODO: set, setw ?? Not working!
# When multiple terminals are attached to the same session, don't let the
# smallest terminal resize all of the sessions. Limit to window level instead.
set-window-option -g aggressive-resize on
# ---------------------------
# KEY BINDINGS
# ---------------------------
# Existing bindings:
# Detatch session: d
# Rename current session: $
# Rename current window: ,
# Swap current pane with previous: {
# Swap current pane with next: }
bind-key x confirm-before 'kill-pane' # already default
bind-key X confirm-before 'kill-window'
bind-key C-X confirm-before 'kill-session'
bind-key C-X confirm-before 'kill-session'
# Navigate without gnarly prefix key
bind -n C-j select-pane -t :.+ # TODO: Temporary. Conflicts with vim.
bind -n C-k select-pane -t :.- # TODO: Temporary. Conflicts with vim.
bind -n C-n select-window -n
bind -n C-p select-window -p
# Move windows back/forward
#bind -n C-i swap-window -t -1
#bind -n C-o swap-window -t +1
# Move pane
#bind -n C-h choose-window "join-pane -v -s "%%"
#bind -n C-l choose-window "join-pane -h -s "%%"
bind -n C-h command-prompt -p "join pane from:" "join-pane -s '%%'"
bind -n C-l command-prompt -p "send pane to:" "join-pane -t '%%'"
# Select next(j)/previous(k) pane in numerical order
#bind-key j select-pane -t :.+
#bind-key k select-pane -t :.-
#bind-key o select-pane -t :.+ # (Also replace the default pane cycle.)
#bind-key O select-pane -t :.-
#bind-key n select-window -n
#bind-key p select-window -p
# Common layouts (use C-b <Space> to cycle all presets)
# Replaces "select window" bindings, 0-9
bind-key Space select-layout even-horizontal # Normally next-layout
bind-key C-space next-layout
# This was just `split-window`; now we do a re-layout.
bind-key '"' split-window \; select-layout even-horizontal
# Menu to switch sessions.
bind-key S choose-tree -u
bind-key T choose-tree -u
#kind-key I select-layout
# And indexed...
bind-key ` select-layout tile
bind-key 1 select-layout even-horizontal
bind-key 2 select-layout even-vertical
bind-key 3 select-layout main-horizontal
bind-key 4 select-layout main-vertical
bind-key 5 select-layout tiled
# Pane resizing with HJKL
bind H resize-pane -L 15
bind J resize-pane -D 15
bind K resize-pane -U 15
bind L resize-pane -R 15
# Display large visable indicators
bind-key t clock-mode # Large clock
bind-key w display-panes # Pane indices (unique, auto-increment)
# Toggle synchronization (mnemonic: e is for echo
# From https://github.com/tangledhelix/dotfiles/blob/master/tmux.conf
bind e setw synchronize-panes on \; display "Synchronize panes ON (E: off)"
bind E setw synchronize-panes off \; display "Synchronize panes OFF (e: on)"
# ---------------------------
# LAYOUT / STYLE
# ---------------------------
# Monokai is best theme.
# Adapted from: https://github.com/ZachMassia/dotfiles/blob/master/tmux.conf
# Monokai/Molokai hex colors.
# http://www.colourlovers.com/lover/Monokai/colors
# cyan - #00b9d7
# gold/brown - #abaa98
# green - #82cdb9
# off-white #f5f5f5
# orange - #f37259
# pink - #ff3d70
# pink/magenta - #f7208b
# yellow - #f9f5c2
# Status bar position
set-option -g status-position top
# Denote window activity
set-window-option -g monitor-activity on
set-window-option -g window-status-activity-attr none
# Clock
set-window-option -g clock-mode-style 24
set-window-option -g clock-mode-colour colour187 # monokai yellow
# Status Bar Left
set -g status-left '#[fg=colour187][#{session_name}] #I:#P | ' # requires color
set -g status-left-length 70
# Status Bar Window Title Tabs
#set-option -g status-justify centre # justify the window tabs
set-option -g status-justify left # justify the window tabs
# Status Bar Colors
set-option -g status-attr dim
set-option -g status-bg colour237 # slightly brighter than molokai vim tabs
set-option -g status-fg colour187 # monokai yellow
# Window Title Tab Colors
set-window-option -g window-status-attr dim
set-window-option -g window-status-bg colour237 # brighter gray
set-window-option -g window-status-fg colour187 # monokai yellow
set-window-option -g window-status-current-attr dim
#set-window-option -g window-status-current-bg colour161 # monokai pink
#set-window-option -g window-status-current-fg '#000000'
set-window-option -g window-status-current-bg '#000000'
set-window-option -g window-status-current-fg colour161 # monokai pink
# Pane Border Colors
set-option -g pane-active-border-bg '#101010'
set-option -g pane-active-border-fg '#87d700' # monokai-green
set-option -g pane-border-bg '#101010'
set-option -g pane-border-fg '#505050'
# TODO: Not sure what these are.
set-option -g mode-bg '#000000'
set-option -g mode-fg colour187 # monokai yellow
set-option -g message-bg '#000000'
set-option -g message-fg colour187 # monokai yellow
# Set CWD as names
# https://stackoverflow.com/a/37136828
set-window-option -g window-status-current-format '#[fg=white,bold]** #{window_index} #[fg=green]#{pane_current_command} #[fg=colour200]#(echo "#{pane_current_path}" | rev | cut -d'/' -f-3 | rev) #[fg=white]**|'
set-window-option -g window-status-format '#[fg=white,bold]#{window_index} #[fg=colour84]#{pane_current_command} #[fg=colour219]#(echo "#{pane_current_path}" | rev | cut -d'/' -f-3 | rev) #[fg=white]|'
set-option -g status-interval 1
@echelon
Copy link
Author

echelon commented Jun 5, 2022

I'm really glad you found this useful! Cheers!

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