armsultan
12/20/2016 - 8:21 PM

tmux.conf

tmux.conf

#####
# Instructions
####

# Modified from 'The best and greatest tmux.conf ever' https://gist.github.com/spicycode/1229612

#  Install CPU, RAM, and load monitor for use with tmux
#  https://github.com/thewtex/tmux-mem-cpu-load

# BE SURE TO INSTALL TMUX Plugin Manager
# https://github.com/tmux-plugins/tpm
# git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# then Load tmux configurations
#> tmux source-file ~/.tmux.conf

# Once installed load plugins in your session with
#> ctrl-b + I
# Once installed:
# prefix + y = copy line to clipboard
# prefix + ctrl-s = Persist session
# prefix + ctrl-r = Resurect session

# To avoid this warning "warning: reattach-to-user-namespace: unsupported new OS, trying as if it were 10.10":
# reinstall:
# brew uninstall --force reattach-to-user-namespace
# brew install reattach-to-user-namespace

# Install tmux-mem-cpu-load on Mac OSX
# brew install tmux-mem-cpu-load
# Done! You can now use tmux-mem-cpu-load.

# Reloading tmux config
# This can be done either from within tmux, by pressing Ctrl+B and then : to bring up a command prompt, and typing:
# :source-file ~/.tmux.conf
# Or simply from a shell:
# $tmux source-file ~/.tmux.conf

# For all other commands, see cheat sheet:
# http://www.dayid.org/comp/tm.html


# Prefix Key set to defaut Ctrl + b
set -g prefix C-b
bind C-b send-prefix

####
# Shortcut keys
####

# shortcut for synchronize-panes toggle
bind e setw synchronize-panes on \; display "Synchronizing panes!"
bind E setw synchronize-panes off \; display "Deactivated Synchronizing panes!"

# Reload the file with Prefix r
bind r source-file ~/.tmux.conf \; display "Reloaded!"

####
# Settings including active mouse, scrolling and more ...
####

# 0 is too far from ` ;)
set -g base-index 1

#retreuve persisted tmux after restart
#https://github.com/tmux-plugins/tmux-resurrect
set -g @plugin 'tmux-plugins/tmux-resurrect'

# automaticually saves tmux session every 15mins
# https://github.com/tmux-plugins/tmux-continuum
set -g @continuum-restore 'on'

#allow copy and paste from tmux
#https://github.com/tmux-plugins/tmux-yank
set -g @plugin 'tmux-plugins/tmux-yank'

# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on

#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000

setw -g mode-keys vi
set -g mouse on
setw -g monitor-activity on

# mouse fix for mac: http://apple.stackexchange.com/questions/218553/iterm-tmux-isnt-allowing-me-to-scroll-up-with-the-mouse
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 

bind-key v split-window -h
bind-key s split-window -v

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

bind-key M-j resize-pane -D
bind-key M-k resize-pane -U
bind-key M-h resize-pane -L
bind-key M-l resize-pane -R

# Vim style pane selection
bind h select-pane -L
bind j select-pane -D 
bind k select-pane -U
bind l select-pane -R


# Use Alt-vim keys without prefix key to switch panes
bind -n M-h select-pane -L
bind -n M-j select-pane -D 
bind -n M-k select-pane -U
bind -n M-l select-pane -R

# 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

# Shift arrow to switch windows
bind -n S-Left  previous-window
bind -n S-Right next-window

# No delay for escape key press
set -sg escape-time 0

# THEME
#set -g status-bg black
#set -g status-fg white
#set -g window-status-current-bg white
#set -g window-status-current-fg black
#set -g window-status-current-attr bold
#set -g status-interval 60
#set -g status-left-length 30
#set -g status-left '#[fg=green](#S) #(whoami) '
#set -g status-right '#[fg=yellow]#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=white]%H:%M#[default]'


# set-window-option -g status-left " #S "
# set-window-option -g status-left-fg black
# set-window-option -g status-left-bg white
# set-window-option -g status-right " %H:%M %d-%b-%y "
# set-window-option -g status-right-fg black
# set-window-option -g status-right-bg white
# set-window-option -g window-status-format " #I: #W "
# set-window-option -g window-status-current-format " #I: #W "
# set-window-option -g window-status-current-fg green
# set-window-option -g window-status-current-bg black

# set color for status bar
set-option -g status-bg colour235 #base02
set-option -g status-fg yellow #yellow
set-option -g status-attr dim 
# set window list colors - red for active and cyan for inactive
set-window-option -g window-status-fg brightblue #base0
set-window-option -g window-status-bg colour236 
set-window-option -g window-status-attr dim
set-window-option -g window-status-current-fg brightred #orange
set-window-option -g window-status-current-bg colour236 
set-window-option -g window-status-current-attr bright
set -g status-left '#[fg=red]#[bg=colour236](#S) #(whoami) |'
set -g status-left-length 60

# uptime in linux (tested in Ubuntu) and OS X
#set -g status-right '#[fg=white,nobright][ #[fg=black,bright]#(uptime | rev | cut -d":" -f1 | rev | sed s/,//g )#[fg=white,nobright] ]'

# Install tmux-mem-cpu-load on Mac OSX: 'brew install tmux-mem-cpu-load'
set -g status-right '#[fg=white,nobright][ #[fg=black,bright]#(tmux-mem-cpu-load)#[fg=white,nobright] ]'

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'

# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'git@github.com/user/plugin'
# set -g @plugin 'git@bitbucket.com/user/plugin'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'