Skip to content

Instantly share code, notes, and snippets.

@niklasad1
Last active June 3, 2018 09:42
Show Gist options
  • Save niklasad1/0f2e2c7246b4e833937b9f81743bf9ee to your computer and use it in GitHub Desktop.
Save niklasad1/0f2e2c7246b4e833937b9f81743bf9ee to your computer and use it in GitHub Desktop.
# Initial setup
set -g default-shell /bin/zsh
set -g default-terminal screen-256color
set -g status-keys vi
# Prefix
set-option -g prefix C-a
unbind-key C-a
bind-key C-a send-prefix
set -g base-index 1
# Easy config reload
bind-key r source-file ~/.tmux.conf \; display-message "tmux.conf reloaded."
# Easy clear history
bind-key L clear-history
# Length of the amount of time status messages are displayed
set-option -g display-time 2000
set-option -g display-panes-time 3000
# Set the base-index to 1 rather than 0
set -g base-index 1
set-window-option -g pane-base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
# Key bindings for copy-paste
setw -g mode-keys vi
# Number windows
set-option -g renumber-windows on
# Window activity monitor
setw -g monitor-activity on
set -g visual-activity on
# Set easier window split keys
bind-key v split-window -h
bind-key h split-window -v
# 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
# Allow the arrow key to be used immediately after changing windows.
set-option -g repeat-time 0
# Shift arrow to switch windows
bind -n S-Left previous-window
bind -n S-Right next-window
# Double press <prefix> to move to last window
bind-key C-b last-window
# No delay for escape key press
set -sg escape-time 0
# Window activity monitor
setw -g monitor-activity on
set -g visual-activity on
# Theme
set -g window-status-current-bg green
set -g window-status-current-fg black
set -g window-status-current-attr bold
set-option -g message-bg colour237
set-option -g message-fg colour231
set-option -g pane-border-fg green
set-option -g pane-active-border-fg green
# Status Bar
set -g status-justify centre
set -g status-bg black
set -g status-fg white
set -g status-interval 60
set -g status-left-length 30
set -g status-left '#[fg=green][#S] #(whoami)@#H'
set -g status-right '#[fg=green]#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=green]%H:%M'
# VIM
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
# Plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-resurrect'
run '~/.tmux/plugins/tpm/tpm'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment