Skip to content

Instantly share code, notes, and snippets.

@vicenterocha
Created August 2, 2020 22:50
Show Gist options
  • Save vicenterocha/cde75898d81b6a00536d9403eb879609 to your computer and use it in GitHub Desktop.
Save vicenterocha/cde75898d81b6a00536d9403eb879609 to your computer and use it in GitHub Desktop.
# .tmux.conf of deanbodenham, based on others (see below)
# last modified: 7 July 2019
# Using tmux 2.6, after 18 Oct 2015
#
## This tmux.conf is based on:
#check out this page for a tmux conf (basis for this one):
#http://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/
#
#thanks to dothebarbwa
#https://www.reddit.com/r/unixporn/comments/3cn5gi/tmux_is_my_wm_on_os_x/
#with my own modifications
#
#Remember: prefix-? shows all keybindings
#Priority: prefix key and reloading tmux.conf:
#-------------------------------------------------------#
#change prefix from C-b to C-a
unbind C-b
set -g prefix C-a
#bind C-a C-a to 'home', or start of line, which was C-a previously
bind C-a send-prefix
#reload tmux.conf message
bind r source-file ~/.tmux.conf \; display "Reloaded ~/.tmux.conf"
#-------------------------------------------------------#
#Create R development environment with multiple windows
#-------------------------------------------------------#
#start off by renaming current window to R, then split, etc
bind F4 \
select-window -t :=1 \;\
rename-window 'R' \;\
split-window -h -c '#{pane_current_path}' \;\
new-window -c '#{pane_current_path}' \;\
rename-window 'scripts' \;\
new-window -c '#{pane_current_path}' \;\
rename-window 'git' \;\
new-window -c '#{pane_current_path}' \;\
rename-window 'tests' \;\
select-window -t :=1 \;\
display "R development environment created"
#-------------------------------------------------------#
#Pane navigation non-standard because of resizing pane prefix-L
#-------------------------------------------------------#
bind -r b previous-window
bind -r n next-window
bind -r p last-window
#-------------------------------------------------------#
#Terminal admin:
#-------------------------------------------------------#
#set mouse off/on - if off, forces you to use keyboard with prefix-[
#set -g mouse off
set -g mouse on
#256 colours
set -g default-terminal "screen-256color"
# start with window 1 (instead of 0)
set -g base-index 1
# start with pane 1
set -g pane-base-index 1
# use vi mode - not sure what these do...
setw -g mode-keys vi
set -g status-keys vi
#setw -g utf8 on
#set -g status-utf8 on
#-------------------------------------------------------#
#PANE NAVIGATION/MANAGEMENT
#-------------------------------------------------------#
# splitting panes
#bind \ split-window -h
#bind - split-window -v
bind \\ split-window -h -c '#{pane_current_path}'
bind - split-window -v -c '#{pane_current_path}'
# open new panes in current path
bind c new-window -c '#{pane_current_path}'
# Use Alt-arrow keys WITHOUT PREFIX KEY to switch panes
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
bind h select-pane -L
bind l select-pane -R
bind k select-pane -U
bind j select-pane -D
#Resizing panes:
bind -r J resize-pane -D 2
bind -r K resize-pane -U 2
bind -r H resize-pane -L 2
bind -r L resize-pane -R 2
#-------------------------------------------------------#
#-------------------------------------------------------#
#Pane copy/pasting
#http://jasonwryan.com/blog/2011/06/07/copy-and-paste-in-tmux/
#-------------------------------------------------------#
#unbind [
#bind Escape copy-mode
bind C-v paste-buffer
#bind-key -t vi-copy 'v' begin-selection
#bind-key -t vi-copy 'y' copy-selection
#-------------------------------------------------------#
#-------------------------------------------------------#
#Setting escape time delay to be smaller
#to make tmux more responsive to commands
#-------------------------------------------------------#
set -s escape-time 1
#-------------------------------------------------------#
#-------------------------------------------------------#
#tmux resurrect
#https://github.com/tmux-plugins/tmux-resurrect
# tmux resurrect keys:
# prefix + Ctrl-s - save
# prefix + Ctrl-r - restore
# tmux resurrect folder:
# ~/.tmux/resurrect
#-------------------------------------------------------#
#activate tmux-resurrect
run-shell ~/build/tmux-resurrect/resurrect.tmux
#resurrect pane contents
#https://github.com/tmux-plugins/tmux-resurrect/blob/master/docs/restoring_pane_contents.md
set -g @resurrect-capture-pane-contents 'on'
#change defaults for resurrect (two steps)
#1. unbind the current defaults C-s and C-r
unbind-key -T prefix C-s
unbind-key -T prefix C-r
#2. Still use prefix C-s and C-r, but now ask for (y/n) response before saving/restoring.
#This assumes tmux-resurrect is saved to ~/build/tmux-resurrect folder
bind-key -T prefix C-s confirm-before -p 'Save this tmux session? (y/n)' 'run-shell ~/build/tmux/tmux-resurrect/scripts/save.sh'
bind-key -T prefix C-r confirm-before -p 'Resurrect last tmux session? (y/n)' 'run-shell ~/build/tmux/tmux-resurrect/scripts/restore.sh'
#-------------------------------------------------------#
#end of tmux resurrect
#-------------------------------------------------------#
#-------------------------------------------------------#
#NOTE:
#reattach-to-user-namespace must be installed
# On OSX, use:
#brew install reattach-to-user-namespace
#
#For opening Skim (and perhaps for copy/pasting)
#http://www.economyofeffort.com/2013/07/29/reattach-to-user-namespace-the-fix-for-your-tmux-in-os-x-woes/
#also have:
set-option -g default-command "reattach-to-user-namespace -l ${SHELL}"
#in ~/.tmux-osx.conf
#-------------------------------------------------------#
if-shell 'test "$(uname)" = "Darwin"' 'source ~/.tmux-osx.conf'
#-------------------------------------------------------#
#### COLOUR (Solarized dark)
## default statusbar colors
set-option -g status-bg colour235 #base02
set-option -g status-fg yellow #yellow
#
## pane number display
set-option -g display-panes-active-colour blue #blue
set-option -g display-panes-colour brightred #orange
## clock
set-window-option -g clock-mode-colour green #green
#
## current session
set -g status-left ' #S. '
set -g status-left-length 15
#
## window list
set -g window-status-format "#[fg=colour8] #I #[fg=colour231]#W#[fg=colour166]#F "
set -g window-status-current-format "#[fg=colour117,bg=colour31] #I #[fg=colour231]#W#[fg=colour234]#F "
set -g window-status-separator ""
#
## battery and pomo status <http://git.io/zMf0IA>
set -g status-right ' #(pomo l) #(~/.i3/conky/battery_info) #(~/.i3/conky/vpn) '
set -g status-interval 1
set -g status-right-length 100
#
set -s escape-time 50
### End of tmux.conf
### Version 7 July 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment