Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@stuart-warren
Created May 4, 2020 09:52
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 stuart-warren/b389c4baa8d4ca20b755d2ebc52cfb04 to your computer and use it in GitHub Desktop.
Save stuart-warren/b389c4baa8d4ca20b755d2ebc52cfb04 to your computer and use it in GitHub Desktop.
basic tmux
# Tmux should be pretty, we need 256 color for that
set -g default-terminal "screen-256color"
# Tmux uses a 'control key', let's set it to 'Ctrl-a'
# Reason: 'Ctrl-a' is easier to reach than 'Ctrl-b'
set -g prefix C-a
unbind C-b
# mouse options
set -g mouse on
# move around buffer like vi
setw -g mode-keys vi
unbind [
bind Escape copy-mode
# command delay? We don't want that, make it short
set -sg escape-time 1
# Set the numbering of windows to go from 1 instead
# of 0 - silly programmers :|
set-option -g base-index 1
setw -g pane-base-index 1
# Allow us to reload our Tmux configuration while
# using Tmux
bind r source-file ~/.tmux.conf \; display "Reloaded!"
is_vim="tmux display-message -p '#{pane_current_command}' \
| grep -iqE '^+(\\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"
# Getting interesting now, we use the vertical and horizontal
# symbols to split the screen
bind c new-window -c '#{pane_current_path}'
bind | split-window -h -c '#{pane_current_path}'
bind _ split-window -v -c '#{pane_current_path}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment