Skip to content

Instantly share code, notes, and snippets.

@suciuvlad
Last active February 25, 2016 11:35
Show Gist options
  • Select an option

  • Save suciuvlad/7ad7a53fdddddabcf95e to your computer and use it in GitHub Desktop.

Select an option

Save suciuvlad/7ad7a53fdddddabcf95e to your computer and use it in GitHub Desktop.
tmux config
set-option -g default-command "reattach-to-user-namespace -l zsh"
set -g default-terminal "screen-256color"
set -g history-limit 50000
# use VI
set-window-option -g mode-keys vi
# Decrease command delay to not interfere with vim
# don't wait for an escape sequence after hitting
# Esc. fixes insert mode exit lag in vim
set -sg escape-time 0
# Use ctrl-a instead of ctrl-b
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# horizontal and vertical splits
unbind ^T
bind ^T split-window -h -p 20
unbind |
bind | split-window -h
unbind _
bind _ split-window
# Resize
unbind ^A
bind ^A resize-pane -Z
# cycle through panes
unbind ^W
bind ^W select-pane -t :.+
unbind Right
bind Right resize-pane -R 8
unbind Left
bind Left resize-pane -L 8
unbind Up
bind Up resize-pane -U 4
unbind Down
bind Down resize-pane -D 4
#
unbind h
bind h select-pane -L
unbind j
bind j select-pane -D
unbind k
bind k select-pane -U
unbind l
bind l select-pane -R
# smart pane switching with awareness of vim splits
# bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
# bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
# bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
# bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
# bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l"
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys 'C-\\') || tmux select-pane -l"
#
set -g status-left ' '
set -g status-right ' '
# Change window indexing
set -g base-index 1
# Change pane indexing
set-window-option -g pane-base-index 1
# Highlight active window
set-window-option -g window-status-current-bg "#BCD92A"
# 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"
# reload config
unbind r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
set-option -g status-utf8 on
# force tmux to use utf-8
setw -g utf8 on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment