Skip to content

Instantly share code, notes, and snippets.

@InAnimaTe
Created February 15, 2018 18:56
Show Gist options
  • Save InAnimaTe/43fa65a090358535c06632d4fbfc66e3 to your computer and use it in GitHub Desktop.
Save InAnimaTe/43fa65a090358535c06632d4fbfc66e3 to your computer and use it in GitHub Desktop.
Tmux Configuration
# unbind some default keybindings
unbind C-b
# set prefix key to ctrl-a
set -g prefix C-a
# lower command delay
set -sg escape-time 1
# start first window and pane at 1, not zero
set -g base-index 1
set -g pane-base-index 1
# bind r to reloading the config file
bind r source-file ~/.tmux.conf \; display "Reloaded tmux config file."
# pass through a ctrl-a if you press it twice
bind C-a send-prefix
# better mnemonics for splitting panes!
bind | split-window -h
bind - split-window -v
# vim / xmonad style bindings for pane movement
### Going to comment these since I will never use them. Utilizing the 'k' for killing windows below.
#bind -r h select-pane -L
#bind -r j select-pane -D
#bind -r k select-pane -U
#bind -r l select-pane -R
# Utilize 'k' to kill current session
bind k kill-session
# And lets do a simple C + w to kill windows, just like tabs in chrome
bind-key -n C-k kill-window
bind-key -n C-w kill-pane
#bind-key -n M-w kill-pane ## Cant do this as it actually applies to iTerm atm.
# Window movement with shift and arrow keys!
#bind -n S-Right next-window
#bind -n S-Left previous-window
# Pane movement with shift and arrow keys
bind -n S-Left select-pane -L
bind -n S-Right select-pane -R
bind -n S-Up select-pane -U
bind -n S-Down select-pane -D
# Lets setup window switching with Ctrl+Shift+Arrow L/R
bind -n C-S-Left previous-window
bind -n C-S-Right next-window
# And create new windows with <prefix>+n
#bind n new-window
## Instead use a template file
bind n new-window \; source-file ~/.tmux/default_new_window
bind-key -n C-t new-window \; source-file ~/.tmux/default_new_window
# And lets enable a shortcut to load this template
bind f source-file ~/.tmux/default_new_window
# vim / xmonad style bindings for window movement
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# shift-movement keys will resize panes
#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
## Since I never use these^
#enable mouse support
#setw -g mode-mouse on
#set -g mouse-select-pane on
#set -g mouse-resize-pane on
#set -g mouse-select-window on
# In with the new:
set-option -g -q mouse on
# turn on 256 color support in tmux
set -g default-terminal "screen-256color"
# use UTF8
#set -g utf8
#set-window-option -g utf8 on
##### COLORS!!!
# fiddle with colors of status bar
set -g status-fg white
set -g status-bg colour234
# fiddle with colors of inactive windows
#setw -g window-status-fg cyan
setw -g window-status-bg colour234
#setw -g window-status-attr dim
# change color of active window
#setw -g window-status-current-fg white
#setw -g window-status-current-bg colour88
#setw -g window-status-current-attr bright
# set color of regular and active panes
#set -g pane-border-fg colour238
#set -g pane-border-bg default
#set -g pane-active-border-fg green
#set -g pane-active-border-bg default
# make sure our current window bg blends with the status bar
set -g window-status-current-bg colour234
# ensure the current window text is green so it blends in
set -g window-status-current-fg colour46
# use a grey for the other windows just chillin there
set -g window-status-fg colour245
### NOTE: The following FG/BG are actually swapped!!! See http://sourceforge.net/p/tmux/tickets/89/ as apparantly, this is default?
# set a while fg on window activites, and maintain our blended status bar
set -g window-status-activity-bg colour15
set -g window-status-activity-fg colour234
# set a magenta fg for window beeps, and maintain our blended status bar
set -g window-status-bell-bg magenta
set -g window-status-bell-fg colour234
# Set our pane border color changes based on focus
setw -g pane-border-fg white
setw -g pane-active-border-fg red
# set color of command line
#set -g message-fg white
#set -g message-bg colour22
#set -g message-attr bright
# configure contents of status bar
#set -g status-utf8 on
#set -g status-left-length 40
#set -g status-left "#[fg=green]\"#S\""
#set -g status-right "#[fg=green] #h | %d %b %R"
set -g status-justify centre
setw -g monitor-activity on
## This gets annoying
set -g visual-activity off
# navigate using vim-style keys
setw -g mode-keys vi
# copy/paste using vim-style keys
bind Escape copy-mode
unbind p
bind p paste-buffer
bind -n C-v paste-buffer
bind -t vi-copy 'v' begin-selection
bind -t vi-copy 'y' copy-selection
# Copy mode for pageup/down
bind-key -T root PPage if-shell -F "#{alternate_on}" "send-keys PPage" "copy-mode -e; send-keys PPage"
bind-key -t vi-copy PPage page-up
bind-key -t vi-copy NPage page-down
# And for my scrollwheel
bind-key -T root WheelUpPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M"
bind-key -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M"
bind-key -t vi-copy WheelUpPane halfpage-up
bind-key -t vi-copy WheelDownPane halfpage-down
# xclip support (commented as this often doesn't make sense on remote servers)
#bind C-c run "tmux save-buffer - / xclip -i -sel clipboard"
#bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"
# set up aliases for temporarily maximizing panes
unbind Up
#bind Up new-window -d -n tmp \; swap-pane -s tmp.1 \; select-window -t tmp
bind Up resize-pane -Z
unbind Down
#bind Down last-window \; swap-pane -s tmp.1 \; kill-window -t tmp
bind Down resize-pane -Z
# set up alias for turning on logging
bind P pipe-pane -o "cat >>~/#W.log" \; display "Toggled logging to ~/#W.log"
#sync up panes
bind s set -g synchronize-panes
#configure the status bar some moar
set -g status-interval 30
set -g status-left-length 30
set -g status-right-length 90
set -g status-left '#(whoami)@#(hostname -s)'
set -g status-right '#(cut -d " " -f 1-3 /proc/loadavg) | #(hostname) | %m-%d-%y | %H:%M'
#set-window-option -g window-status-current-bg white
#set-window-option -g window-status-current-fg black
setw -g automatic-rename
#set-window-option -g automatic-rename off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment