Skip to content

Instantly share code, notes, and snippets.

@jdhao
Created April 18, 2019 07:34
Show Gist options
  • Save jdhao/6b7d2aa461cca2290391cb231344a46c to your computer and use it in GitHub Desktop.
Save jdhao/6b7d2aa461cca2290391cb231344a46c to your computer and use it in GitHub Desktop.
Tmux configuratons
#######################################################################
# key bindings #
#######################################################################
# SET THE PREFIX TO CTRL-W.
unbind C-b
set-option -g prefix C-w
bind-key C-w send-prefix
# make split pane similar to vim
bind s split-window -v
bind v split-window -h
# choose a session from the session list, see https://is.gd/dyLvII
bind S choose-session
# move around panes with hjkl, as one would in vim after pressing ctrl-w
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# resize panes more easiyly
bind < resize-pane -L 10
bind > resize-pane -R 10
bind - resize-pane -D 10
bind + resize-pane -U 10
# 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
# Reload tmux config, extract from Tmux man page
bind-key r source-file ~/.tmux.conf \; \
display-message "source-file done"
#######################################################################
# settings #
#######################################################################
# prevent delay after pressing esc key
# credit: https://www.johnhawthorn.com/2012/09/vi-escape-delays/
# and https://goo.gl/YaqhdB
set -s escape-time 10
set -g default-terminal "screen-256color"
# if terminal supports true color, use the following options
set -ga terminal-overrides ",xterm-256color*:Tc"
#setw -g xterm-keys on
# Enable mouse control (clickable windows, panes, resizable panes)
# for tmux 2.1 or later?
set -g mouse on
# make vim work seamlessly with tmux
set -g focus-events on
# statusbar settings
# set -g status-position bottom
# set -g status-justify left
# set -g status-bg green
# set -g status-fg red
# set -g status-right-length 100
# set -g status-left-length 20
# # show load avg info on status bar, revised from https://gist.github.com/mutomasa/2730263
# set -g status-right "#[fg=blue,bold]#(uptime | cut -d ',' -f 4-)"
# set -g status-left '#[fg=blue][#S] #[default]'
#######################################################################
# tmux plugins settings #
#######################################################################
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# restore tmux session after system restart
set -g @plugin 'tmux-plugins/tmux-resurrect'
# tmux theme pack
# set -g @plugin 'jimeh/tmux-themepack'
# set -g @themepack 'powerline/block/cyan'
# solarzied theme
# set -g @plugin 'seebi/tmux-colors-solarized'
# set -g @colors-solarized '256'
# neodrak color theme
# set -g @plugin 'KeitaNakamura/neodark.vim'
# onedark theme for tmux, see https://github.com/odedlaz/tmux-onedark-theme
set -g @plugin 'odedlaz/tmux-onedark-theme'
# base16 color theme
# set -g @plugin 'jatap/tmux-base16-statusline'
# set -g @base16-statusline 'main'
set -g @plugin 'KeitaNakamura/tmux-statusbar'
# automatically install tmux plugin on new machines,
# see https://github.com/tmux-plugins/tpm/blob/master/docs/automatic_tpm_installation.md
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"
run -b '~/.tmux/plugins/tpm/tpm'
@jdhao
Copy link
Author

jdhao commented Apr 18, 2019

The above settings are tested on Tmux 2.8-rc and should work for latest versions of Tmux. A list of articles I have written about Tmux can be found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment