Skip to content

Instantly share code, notes, and snippets.

@ben-albrecht
Created May 30, 2018 17:52
Show Gist options
  • Save ben-albrecht/5a2b17a6992617495450ad9de3614b8f to your computer and use it in GitHub Desktop.
Save ben-albrecht/5a2b17a6992617495450ad9de3614b8f to your computer and use it in GitHub Desktop.
# Rebind PREFIX to backtick: `
unbind C-b
set -g prefix '`' ; bind '`' send-prefix
# Default shell = /usr/local/bin/bash (for OS X)
if-shell "uname | grep -q Darwin" "set-option -g default-shell /usr/local/bin/bash"
# OS X specific attempt to copy/paste with clipboard
set-option -g default-command "reattach-to-user-namespace -l bash" # or bash...
# Not exactly sure what this does...
set-window-option -g mode-keys vi
# Vim-style selection and copying
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
# Moving between panes vim-style (hjkl)
bind-key k select-pane -U
bind-key j select-pane -D
bind-key h select-pane -L
bind-key l select-pane -R
# Vim colors
set -g default-terminal "xterm"
# into the .tmux.conf file will cause tmux to write a message and highlight the window inside of which the activity took place (that is, something was written to the output).
# Reload tmux config so we can pick up changes to this file without needing to restart tmux
bind r source-file ~/.tmux.conf \; display "Reloaded tmux configuration!"
# Index windows from 1, not 0, so they line up a little better
# with the order of the number keys on the keyboard
set -g base-index 1
setw -g pane-base-index 1
# Reduce the command delay time to something a bit shorter
set -sg escape-time 0
# set-option -sg escape-time 0
# Extend the repeat interval for repeatable commands (e.g., resize-pane)
set -sg repeat-time 1000
# Refresh the status bar every second.
set -g status-interval 1
# Default is 2000
set -g history-limit 100000
# When a smaller terminal connects to a tmux client, it shrinks to fit it.
# The clients attached with bigger displays see this constrained view.
# aggressive-resize makes it such that the window is only resized if the
# smaller client is actively looking at it.
setw -g aggressive-resize on
# Split windows more intuitively (except for the fact that tmux doesn't
# understand that a horizontal split means the pane should be split down the
# middle horizontally, and likewise for a vertical split).
bind | split-window -h # horizontal columns
bind - split-window -v # vertical rows
# Renumber windows
bind m command-prompt -p "move window to:" "move-window -t '%%'"
# Status bar colors
set -g status-fg white
set -g status-bg colour234
# Window list
setw -g window-status-fg green
setw -g window-status-bg default
setw -g window-status-attr dim
setw -g window-status-current-fg white
setw -g window-status-current-bg blue
setw -g window-status-current-attr bright
# Pane borders
set -g pane-border-fg default
set -g pane-border-bg default
set -g pane-active-border-fg green
set -g pane-active-border-bg blue
# Command line
set -g message-fg white
set -g message-bg red
set -g message-attr bright
# Status Bar Items
set -g status-position top
set -g status-left-length 100
set -g status-left "#[fg=yellow]#I #[fg=green]#P #S #[fg=red]#W #[fg=blue]#T"
set -g status-right "#[fg=cyan]#H #[fg=yellow]%a %b %e %T"
set -g status-justify centre
# Monitor windows for activity
setw -g monitor-activity on
set -g visual-activity on
#
# Experiments
#
# Smart pane switching with awareness of vim splits
# vim-tmux (TODO)
#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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment