Created
June 13, 2024 19:37
-
-
Save FreedomBen/9c52a6fa1543689798a8a42b6a295dfc to your computer and use it in GitHub Desktop.
Tmux config file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set vi keys for copy mode | |
set-option -g status-keys vi | |
set-window-option -g mode-keys vi | |
set-option -g history-limit 10000 | |
# Copy mode info: default enter copy mode is C-[ and paste is C-] | |
# `prefix + p` pastes the latest buffer (for some reason Ctrl + ] doesn't work) | |
bind p paste-buffer | |
# `tmux prefix + Escape` or 'Ctrl-Q' starts copy mode. | |
# You can also use prefix + [ | |
bind Escape copy-mode | |
bind -n C-q copy-mode | |
# renumber windows automatically when one closes | |
set-option -g renumber-windows on | |
# Increase display time so we can read the messages | |
# https://unix.stackexchange.com/a/339454/34855 | |
# To temporarirly change in session, run `<prefix>:set-option display-time 4000` | |
set-option -g display-time 4000 | |
# Make Ctrl-a Ctrl-a switch between last selected window like screen | |
bind C-a run 'tmux last-window' | |
# Make Ctrl-a Ctrl-n and Ctrl-a Ctrl-p work | |
bind C-p run 'tmux previous-window' | |
bind C-n run 'tmux next-window' | |
# More straight forward key bindings for splitting | |
unbind C-d | |
unbind C-s | |
# The -c is the starting directory. Default is current working directory | |
#bind c new-window -c "#{pane_current_path}" # If you want ctrl a to open in same directory then use this | |
bind C-d split-window -h -c "#{pane_current_path}" | |
bind C-s split-window -v -c "#{pane_current_path}" | |
# Allow using the vim style switching commands | |
unbind h | |
unbind j | |
unbind k | |
unbind l | |
unbind C-h | |
unbind C-j | |
unbind C-k | |
unbind C-l | |
bind h run "tmux select-pane -L" | |
bind j run "tmux select-pane -D" | |
bind k run "tmux select-pane -U" | |
bind l run "tmux select-pane -R" | |
bind C-h run "tmux select-pane -L" | |
bind C-j run "tmux select-pane -D" | |
bind C-k run "tmux select-pane -U" | |
bind C-l run "tmux select-pane -R" | |
# Allow swapping panes with C-r : https://superuser.com/a/1390076/199667 | |
bind C-r swap-pane -s '!' -t $TMUX_PANE | |
# C-o will rotate the panes | |
# Make scrollback work by tricking tmux into thinking there is no alternate screen | |
# supported by this terminal | |
set -ga terminal-overrides ',xterm*:smcup@:rmcup@' | |
# These will use the vim style switching commands smartly between vim splits and tmux splits | |
# See: http://robots.thoughtbot.com/seamlessly-navigate-vim-and-tmux-splits | |
# bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L" | |
# bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D" | |
# bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U" | |
# bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R" | |
# bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l" | |
# Set prefix to C-a like Screen | |
unbind C-b | |
set -g prefix ^A | |
bind a send-prefix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment