Skip to content

Instantly share code, notes, and snippets.

@karlbright
Created January 22, 2016 06:08
Show Gist options
  • Save karlbright/ced9e1ab1b0b73aef14c to your computer and use it in GitHub Desktop.
Save karlbright/ced9e1ab1b0b73aef14c to your computer and use it in GitHub Desktop.
# A better prefix
unbind-key C-b
set -g prefix 'C-a'
bind-key 'C-a' send-prefix
# Use reattach-to-user-namespace to fix clipboard issues
set-option -g default-command "reattach-to-user-namespace -l zsh"
set-environment -g TMUX_COMMAND tmux
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
bind r source-file ~/.tmux.conf \; display "Reloaded!"
set -g status-left-length 70
# Navigation between vim and tmux panes made easy
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?x?)(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"
# New splits
bind-key v split-window -h
bind-key x split-window -v
# Resize splits
bind-key J resize-pane -D 5
bind-key K resize-pane -U 5
bind-key H resize-pane -L 5
bind-key L resize-pane -R 5
# Resize without prefix
bind-key -n C-S-Up resize-pane -U 5
bind-key -n C-S-Down resize-pane -D 5
bind-key -n C-S-Left resize-pane -L 10
bind-key -n C-S-Right resize-pane -R 10
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup copy paste like vim for copy mode
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 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"
# Start indexing at 1, not 0
set-option -g base-index 1
setw -g pane-base-index 1
# Enable 256 colorspace
set -g default-terminal "screen-256color"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment