Skip to content

Instantly share code, notes, and snippets.

@randomradio
Last active February 18, 2019 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save randomradio/b9622cb41102943e7bf79be2dfb5a894 to your computer and use it in GitHub Desktop.
Save randomradio/b9622cb41102943e7bf79be2dfb5a894 to your computer and use it in GitHub Desktop.
tmux configuration. Vim styled keybinding.
# 0 is too far from ` ;)
set -g base-index 1
# reset keys
unbind-key -n S-Left
unbind-key -n S-Right
# custom binding
set -g prefix C-s
bind C-s send-prefix
# color profile. xTerm-256 is also a good one
set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
# renumber after window open/close
set -g renumber-windows on
setw -g mode-keys vi
set -g monitor-activity on
set -g mouse on
# creates new window
bind-key c new-window -c "#{pane_current_path}"
# split within current window
bind-key v split-window -h -c "#{pane_current_path}"
bind-key '"' split-window -v -c "#{pane_current_path}"
# default pane name
# be sure to see note* below
set -g window-status-format '#I:#(pwd="#{pane_current_path}"; echo ${pwd####*/})#F'
set -g window-status-current-format '#I:#(pwd="#{pane_current_path}"; echo ${pwd####*/})#F'
# status bar updates every 15s by default**, change to 1s here
# (this step is optional - a lower latency might have negative battery/cpu usage impacts)
set -g status-interval 2
# Resizing pane, rarely used....since I enabled mouse click.
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
## Alt + * will resize as well.
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
#! this conficts with emacs org-mode demote/promote
# bind -n S-Left previous-window
# bind -n S-Right next-window
# No delay for escape key press
set -sg escape-time 0
# copy and paste, mac osx comes with pbcopy to copy stuff. this is useful
# after I enbled mouse in tmux, I can drag and select a region to copy the text
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "pbcopy"
# Reload tmux config
bind r source-file ~/.tmux.conf
# 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]'
# TPM, plugin manager
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
# 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'

To use this configuration.

You can download this .tmux.conf into your HOME directory or create .tmux.conf in your HOME directory ($HOME) and copy this configuration into it.

Tmux uses prefix before executing your commands. I personally set prefix to Ctrl-s because it's easy to type.

  1. Splitting pane,
  • `prefix' + v splits window vertically
  • `prefix' + s splits window horizontally
  1. Moving between panes, I'm using vim styled keybindings, so hjkl maps to left/down/up/right
  • `prefix' + l move focus to right of current pane
  • `prefix' + h move focus to the left of current pane
  • `prefix' + j move focus to the beneath of current pane
  • `prefix' + k move focus to the above of current pane
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment