Skip to content

Instantly share code, notes, and snippets.

@finchd
Last active July 13, 2022 04:06
Show Gist options
  • Save finchd/e505f4013204fd54d5b6 to your computer and use it in GitHub Desktop.
Save finchd/e505f4013204fd54d5b6 to your computer and use it in GitHub Desktop.
.tmux.conf
# use C-a, since it's on the home row and easier to hit than C-b
set-option -g prefix C-a
unbind-key C-a
bind-key C-a send-prefix
# count windows from one; this means there is no zero
set -g base-index 1
# Easy config reload
bind-key R source-file ~/.tmux.conf \; display-message "tmux.conf reloaded."
# explore using set-titles to get intelligent window titles
#set-titles on #unknown command in tmux 2.0
# vi is good
setw -g mode-keys vi
# Passthrough ctrl, etc. For ^PgUp/^PgDn tabs in vim
setw -g xterm-keys on
# mouse behavior
#pre-2.1 behavior
#setw -g mode-mouse on
#set -g mouse-select-pane on
#set -g mouse-resize-pane on
#2.1 behavior
set -g mouse on
#
set-option -g default-terminal screen-256color
bind-key : command-prompt
# set r to reload the config instead of reload-window (refresh), which you can just swap windows to get.
bind-key r source-file ~/.tmux.conf
bind-key L clear-history
bind-key space next-window
bind-key bspace previous-window
bind-key enter next-layout
# use vim-like keys for splits and windows
bind-key v split-window -h
bind-key s split-window -v
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
# smart pane switching with awareness of vim splits
bind-key -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send C-h) || tmux select-pane -L"
bind-key -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send C-j) || tmux select-pane -D"
bind-key -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send C-k) || tmux select-pane -U"
bind-key -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send C-l) || tmux select-pane -R"
bind-key -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send 'C-\\') || tmux select-pane -l"
bind-key C-l send 'C-l'
bind-key C-o rotate-window
bind-key + select-layout main-horizontal
bind-key = select-layout main-vertical
set-window-option -g other-pane-height 25
set-window-option -g other-pane-width 80
bind-key a last-pane
bind-key q display-panes
bind-key c new-window
bind-key t next-window
bind-key T previous-window
bind-key [ copy-mode
bind-key ] paste-buffer
#both bind-keys for copy-pipe not in v1.6
# Setup 'v' to begin selection as in Vim #uncommenting next 4 to test
#bind-key -t vi-copy v begin-selection
#bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# Update default binding of `Enter` to also use copy-pipe
#unbind-key -t vi-copy Enter
#bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
set-window-option -g display-panes-time 1500
# Status Bar
set-option -g status-interval 1
set-option -g status-utf8 on
#set-option -g status-left '' #Nothing on the left sucks, return to the default
#set-option -g status-right "$(powerline tmux right -w 30)" #not how you use powerline, unfortunately
set-option -g status-right '#(~/perl5/bin/rainbarf) %Y-%m-%d < %H:%M%p < #(hostname)' #hostname doesn't show, maximum right-side length reached?
set-window-option -g window-status-current-fg magenta
set-option -g status-fg default
# Status Bar solarized-dark (default)
set-option -g status-bg black
set-option -g status-fg green
#set-option -g pane-active-border-fg black
#set-option -g pane-border-fg black
# Status Bar solarized-light
if-shell "[ \"$COLORFGBG\" = \"11;15\" ]" "set-option -g status-bg white"
if-shell "[ \"$COLORFGBG\" = \"11;15\" ]" "set-option -g pane-active-border-fg white"
if-shell "[ \"$COLORFGBG\" = \"11;15\" ]" "set-option -g pane-border-fg white"
# Set window notifications
#setw -g monitor-activity on
#set -g visual-activity on
# Enable native Mac OS X copy/paste
#set-option -g default-command "/bin/bash -c 'which reattach-to-user-namespace >/dev/null && exec reattach-to-user-namespace $SHELL -l || exec $SHELL -l'"
# Allow the arrow key to be used immediately after changing windows
set-option -g repeat-time 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment