Skip to content

Instantly share code, notes, and snippets.

@Gavinok
Created December 29, 2018 20:03
Show Gist options
  • Save Gavinok/24a745a402f2bb4fdf3a3514a704152c to your computer and use it in GitHub Desktop.
Save Gavinok/24a745a402f2bb4fdf3a3514a704152c to your computer and use it in GitHub Desktop.
Here is a copy of my tmux conf
#neovim curser support
set -ga terminal-overrides ',*:Ss=\eE[%p1%d q:Se=\eE[2 q'
# Our .tmux.conf file
# Setting the prefix from C-b to C-s
set -g prefix C-a
# Free the original Ctrl-b prefix keybinding
unbind C-b
#setting the delay between prefix and command
set -sg escape-time 1
# Ensure that we can send Ctrl-S to other apps
bind b send-prefix
# Set the base index for windows to 1 instead of 0
set -g base-index 1
# Set the base index for panes to 1 instead of 0
setw -g pane-base-index 1
# Reload the file with Prefix r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# splitting panes
# bind | split-window -h
# bind - split-window -v
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-\) || tmux select-pane -l"
#(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l"
# | grep -iqE '(^|\/)n?vim(diff)?$|emacs.*$' && tmux send-keys C-l) || tmux select-pane -
# 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"
# use vim-like keys for splits and windows
bind-key v split-window -h
bind-key c 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
bind-key space next-window
bind-key bspace previous-window
bind-key enter next-layout
# Easy config reload
bind-key R source-file ~/.tmux.conf \; display-message "tmux.conf reloaded."
# Moving between windows, gnome-terminal style
bind -n C-PgUp select-window -t :-
bind -n C-PgDn select-window -t :+
# open new window gnome-terminal style
bind -n C-T new-window
set-window-option -g xterm-keys on
# move windows forward and backwards, gnome-terminal style
bind-key -n C-S-Left swap-window -t -1
bind-key -n C-S-Right swap-window -t +1
# use the mouse
#-------- Copy Mode (Vim Style) {{{
#------------------------------------------------------
# This section of hotkeys mainly work in copy mode and no where else
# vim keys in copy and choose mode
set-window-option -g mode-keys vi
# copying selection vim style
# http://jasonwryan.com/blog/2011/06/07/copy-and-paste-in-tmux/
# https://github.com/myfreeweb/dotfiles/blob/master/tmux.conf
bind-key Escape copy-mode # enter copy mode; default [
bind-key p paste-buffer # paste; (default hotkey: ] )
bind-key P choose-buffer # tmux clipboard history
bind-key + delete-buffer \; display-message "Deleted current Tmux Clipboard History"
# Send To Tmux Clipboard or System Clipboard
bind-key < run-shell "tmux set-buffer -- \"$(xsel -o -b)\"" \; display-message "Copy To Tmux Clipboard"
bind-key > run-shell 'tmux show-buffer | xsel -i -b' \; display-message "Copy To System Clipboard"
# set the current tmux version (use this variable on if-shell commands)
run-shell "tmux set-environment -g TMUX_VERSION $(tmux -V | cut -c 6-)"
# vim copy mode rebinds for (tmux 2.4+)
# https://shapeshed.com/custom-vim-bindings-in-tmux-2-4/
# https://github.com/tmux/tmux/issues/754#issuecomment-303156000
# https://stackoverflow.com/a/40902312
# Note: rectangle-toggle (aka Visual Block Mode) > hit v then C-v to trigger it
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.4" | bc)" = 1 ]' \
'bind-key -T copy-mode-vi v send-keys -X begin-selection; \
bind-key -T copy-mode-vi V send-keys -X select-line; \
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle; \
bind-key -T choice-mode-vi h send-keys -X tree-collapse ; \
bind-key -T choice-mode-vi l send-keys -X tree-expand ; \
bind-key -T choice-mode-vi H send-keys -X tree-collapse-all ; \
bind-key -T choice-mode-vi L send-keys -X tree-expand-all ; \
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe "xclip -in -selection clipboard"; \
bind-key -T copy-mode-vi y send-keys -X copy-pipe "xclip -in -selection clipboard"'
# vim copy mode rebinds for (tmux 2.3 or lower)
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.4" | bc)" = 1 ]' \
'bind-key -t vi-copy v begin-selection; \
bind-key -t vi-copy V select-line; \
bind-key -t vi-copy C-v rectangle-toggle; \
bind-key -t vi-choice h tree-collapse; \
bind-key -t vi-choice l tree-expand; \
bind-key -t vi-choice H tree-collapse-all; \
bind-key -t vi-choice L tree-expand-all; \
bind-key -t vi-copy MouseDragEnd1Pane copy-pipe "xclip -in -selection clipboard"; \
bind-key -t vi-copy y copy-pipe "xclip -in -selection clipboard"'
#}}}
# Pane resizing
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# Set the default terminal mode to 256color mode
set -g default-terminal "screen-256color"
# enable activity alerts
setw -g monitor-activity on
set -g visual-activity on
set -g message-fg white
set -g message-bg black
set -g message-attr bright
# Status line left side
set -g status-left-length 40
# enable vi keys.
setw -g mode-keys vi
# Log output to a text file on demand
set -g history-limit 10000
#new-window
new-session
# Status Bar
set-option -g status-interval 1
set-option -g status-left ''
set-option -g status-right '%l:%M%p'
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 pane-active-border-fg cyan
set-option -g pane-border-fg cyan
# 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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment