Skip to content

Instantly share code, notes, and snippets.

@nicolasochem
Last active October 21, 2024 17:49
Show Gist options
  • Save nicolasochem/06476623d657329e514a to your computer and use it in GitHub Desktop.
Save nicolasochem/06476623d657329e514a to your computer and use it in GitHub Desktop.
The best tmux configuration in the universe - 2024 version
# Our .tmux.conf file
# Setting the prefix from C-b to C-s
set -g prefix C-s
# Free the original Ctrl-b prefix keybinding
unbind C-b
#setting the delay between prefix and command
set -sg escape-time 1
# Ensure that we can send Ctrl-S to other apps
bind C-s send-prefix
# Set the base index for windows to 1 instead of 0
set -g base-index 1
# Set the base index for panes to 1 instead of 0
setw -g pane-base-index 1
# Reload the file with Prefix r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# splitting panes
bind | split-window -h
bind - split-window -v
# smart pane switching with awareness of vim 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"
# Moving between windows, gnome-terminal style
bind -n C-PgUp select-window -t :-
bind -n C-PgDn select-window -t :+
# open new window gnome-terminal style
bind -n C-T new-window
set-window-option -g xterm-keys on
# # move windows forward and backwards, gnome-terminal style
# # Bind Ctrl+Shift+PgDn to move window forward
# bind-key -n "^[[(5;6~" swap-window -t +1
# # Bind Ctrl+Shift+PgUp to move window backward
# bind-key -n "^[[(6;6~" swap-window -t +1
# type commands in every pane
unbind \;
bind \; set-window-option synchronize-panes
# use vim-bindings for copying and pasting text
unbind [
bind Escape copy-mode
# use vim-bindings for copying and pasting text
unbind [
bind Escape copy-mode
unbind p
bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
bind-key p run "tmux set-buffer \"$(xclip -o -selection clipboard)\"; tmux paste-buffer"
bind-key P run "tmux set-buffer \"$(xclip -o -selection clipboard)\"; tmux paste-buffer"
#unbind p
#bind p run "xclip -o | tmux load-buffer - ; tmux paste-buffer"
#bind-key -t vi-copy 'v' begin-selection
## see http://unix.stackexchange.com/questions/131011/use-system-clipboard-in-vi-copy-mode-in-tmux
#bind-key -t vi-copy 'y' save-buffer
#bind -t vi-copy y copy-pipe 'xclip -i'
#bind -t vi-copy V rectangle-toggle
# Pane resizing
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
# Set the default terminal mode to 256color mode
set -g default-terminal "screen-256color"
# enable activity alerts
setw -g monitor-activity on
set -g visual-activity on
# set the status line's colors
set -g status-fg white
set -g status-bg black
# Set colors for inactive windows in the window list
setw -g window-status-style fg=cyan,bg=default,dim
# Set colors for the active window in the window list
setw -g window-status-current-style fg=white,bg=blue,bold
set -g pane-border-style fg=green,bg=black
set -g pane-active-border-style fg=white,bg=yellow
set -g message-style fg=white,bg=black,bright
# Status line left side
set -g status-left-length 40
set -g status-left "#[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P"
#set -g status-utf8 on
# Status line right side
# 15% | 28 Nov 18:15
#set -g status-right "#(~/battery Discharging) | #[fg=cyan]%d %b %R"
# Update the status bar every sixty seconds
set -g status-interval 60
# Center the window list
set -g status-justify centre
# enable vi keys.
setw -g mode-keys vi
# Open panes in the same directory using the tmux-panes script
#unbind v
#unbind n
#bind v send-keys " ~/tmux-panes -h" C-m
#bind n send-keys " ~/tmux-panes -v" C-m
# Maximize and restore a pane
#unbind Up
#bind Up new-window -d -n tmp \; swap-pane -s tmp.1 \; select-window -t tmp
#unbind Down
#bind Down last-window \; swap-pane -s tmp.1 \; kill-window -t tmp
#
# Log output to a text file on demand
bind P pipe-pane -o "cat >>~/#W.log" \; display "Toggled logging to ~/#W.log"
set -g history-limit 10000
set-option -g status-position top
#new-window
new-session
if-shell "true" "set -g mouse on"
@wonbinbk
Copy link

wonbinbk commented Apr 9, 2022

I'm new to tmux and would like to try this tmux config but I'm afraid it might conflict with my current vim config 😄
Do you have a guide or tutorial on how you use these config files in your work flow?

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