Skip to content

Instantly share code, notes, and snippets.

@paul-english
Created November 16, 2015 22:30
Show Gist options
  • Save paul-english/53d9afad9e957d5976d4 to your computer and use it in GitHub Desktop.
Save paul-english/53d9afad9e957d5976d4 to your computer and use it in GitHub Desktop.
tmux config
unbind C-b
set -g prefix C-Space
set -g mode-keys vi
# Set XTerm key bindings
setw -g xterm-keys on
# Set XTerm overrides
set -g terminal-overrides "xterm*:XT:smcup@:rmcup@"
# Set colors
set-option -g default-terminal "screen-256color"
# Set a Ctrl-b shortcut for reloading your tmux config
bind r source-file ~/.tmux.conf
# Count sessions start at 1
set -g base-index 1
# Set the title bar
set -g set-titles on
set -g set-titles-string "#H #T"
#set -g set-titles-string "#H:#S.#I.#P #W #T"
#set -g set-titles-string "#(whoami) :: #h :: #(curl ipecho.net/plain;echo)"
# Set status bar
set -g status-utf8 on
set -g status-bg black
set -g status-fg white
set -g status-interval 5
set -g status-left-length 90
set -g status-right-length 60
set -g status-left "#[fg=Green]#(whoami)#[fg=white]::#[fg=blue]#(hostname -s)#[fg=white]::#[fg=yellow]#(curl ipecho.net/plain;echo) "
set -g status-justify left
set -g status-right '#[fg=Cyan]#S #[fg=white]%a %d %b %R'
set-window-option -g window-status-current-fg white
set-window-option -g window-status-current-bg green
set-window-option -g window-status-current-attr bright
# Reordering Windows
bind-key -n S-Left swap-window -t -1
bind-key -n S-Right swap-window -t +1
set-option -g renumber-windows on
# Mouse settings
set -g mouse-utf8 on
set -g mouse on
# make scrolling with wheels work
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
# Copy-paste integration
# NOTE: requires `brew install reattach-to-user-namespace`
set-option -g default-command "reattach-to-user-namespace -l zsh"
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' to begin selection as in Vim
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 -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
# Bind ']' to use pbpaste
bind ] run "reattach-to-user-namespace pbpaste | tmux load-buffer - && tmux paste-buffer"
# Things
# http://evertpot.com/osx-tmux-vim-copy-paste-clipboard/
# http://montanaflynn.me/2014/09/devops/enable-tmux-scrolling-in-iterm2/
# https://justin.abrah.ms/dotfiles/tmux.html
# https://danielmiessler.com/study/tmux/
# Cool things
bind-key S command-prompt -p ssh: "new-window -n %1 'ssh %1'"
bind-key | split-window -h
bind-key - split-window -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment