Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@relaxdiego
Last active February 3, 2024 02:26
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save relaxdiego/bda8694d38f4c635eee40d15bec3e73e to your computer and use it in GitHub Desktop.
Save relaxdiego/bda8694d38f4c635eee40d15bec3e73e to your computer and use it in GitHub Desktop.
#
# Installation:
# mkdir -p ~/.byobu
# wget -O ~/.byobu/keybindings.tmux byobu.relaxdiego.com
# tmux source-file ~/.byobu/keybindings.tmux
#
# Rebind Ctrl-a as the prefix
unbind-key -n C-a
set -g prefix ^A
set -g prefix2 F12
# Reloads the config file
bind r source-file ~/.byobu/keybindings.tmux \; display "Config reloaded!"
# Unbind Meta-left and Meta-right keys since they're more often
# used for quickly jumping between words on the terminal.
unbind-key -n M-Left
unbind-key -n M-Right
# Press <prefix> and then 'a' to send Ctrl-a to the application
bind a send-prefix
# Send prefix to an application by pressing the prefix twice
bind C-a send-prefix
# synchronize-panes shortcut
bind y set-window-option synchronize-panes
# <prefix> \ and <prefix> - require less keystrokes
# and are more intuitive than the defaults.
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
#
# BEGIN Adapted from https://stackoverflow.com/a/40902312
#
run-shell 'tmux setenv -g TMUX_VERSION $(tmux -V | sed -E "s/^tmux +([\.0-9]+).*/\1/g")'
# NOTE: tmux doesn't use SemVer. It just increments by 0.1 with every release.
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.9" | bc)" = 1 ]' ' \
bind-key \ split-window -h -c "#{pane_current_path}"'
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.9" | bc)" = 1 ]' ' \
bind \\ split-window -h -c "#{pane_current_path}"'
#
# END
#
# These bindings allow you to stay in your keyboard's home
# row when moving between panes. Assuming, of course, that
# you've swapped your Ctrl and Caps Lock keys which you should!
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Resize panes using the home row too!
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
# Make copy/paste same as vim
bind Escape copy-mode
unbind p
bind p paste-buffer
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
bind-key -T copy-mode-vi 'y' send-keys -X copy-selection-and-cancel
set -g status-left "#[fg=colour248]S:#S W:#I P:#P#{?pane_synchronized, #[fg=colour255]#[bg=red](panes are synced. 'Ctrl-A y' to toggle)#[default],} "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment