Created
July 4, 2021 03:47
-
-
Save marcopaganini/704ad467c382296176cafcc08dff518d to your computer and use it in GitHub Desktop.
My tmux.conf file supporting truecolor terminals and many other hacks.
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
# tmux configuration file. | |
# Save as $HOME/.tmux.conf | |
# Marco Paganini <[email protected]> | |
# | |
# Useful command: | |
# tmux new -D -A -s session_name | |
# | |
# This will create a new session if the specified session does not | |
# exist. If it does, it will detach that session and attach to it. | |
# C-a FTW! | |
set-option -g prefix C-a | |
# Common binds (screen-like) | |
bind-key C-a last-window | |
bind-key C-Space next-window | |
bind-key C-d detach | |
bind-key Space next-window | |
bind-key BSpace previous-window | |
bind-key k confirm-before -p "kill-pane #P? (y/n)" kill-pane | |
# No mouse support by default. | |
set -g mouse off | |
# Ctrl-A H/h turn on/off output logging. | |
bind-key H pipe-pane "exec cat >>$HOME/'tmux-#H-#S-#P.log'" \; display-message 'Started logging to $HOME/tmux-#H-#S-#P.log' | |
bind-key h pipe-pane \; display-message 'Ended logging to $HOME/tmux-#H-#S-#P.log' | |
# Use vi keys in copy and choice modes and improve some bindings. | |
# Use list-keys -t vi-copy to see all bindings. | |
# Enter in copy mode uses xclip to copy the selection to the | |
# cut buffer and primary clipboard. | |
setw -g mode-keys vi | |
bind P paste-buffer | |
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection | |
bind-key -T copy-mode-vi 'r' send-keys -X rectangle-toggle | |
bind-key -T copy-mode-vi Home send-keys -X start-of-line | |
bind-key -T copy-mode-vi End send-keys -X end-of-line | |
bind-key -T copy-mode-vi C-PPage send-keys -X history-top | |
bind-key -T copy-mode-vi C-NPage send-keys -X history-bottom | |
bind-key -T copy-mode-vi 'y' send-keys -X copy-selection-and-cancel | |
bind-key -T copy-mode-vi 'Y' send-keys -X copy-pipe-and-cancel "xclip -sel clip -i" | |
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard" | |
# word separators for automatic word selection | |
setw -g word-separators ' @"=()[]' | |
setw -ag word-separators "'" | |
# Pane navigation: Use Meta-hjkl or Meta-Arrows, directly (no prefix). | |
bind-key -n M-h select-pane -L | |
bind-key -n M-j select-pane -D | |
bind-key -n M-k select-pane -U | |
bind-key -n M-l select-pane -R | |
bind-key -n M-Left select-pane -L | |
bind-key -n M-Down select-pane -D | |
bind-key -n M-Up select-pane -U | |
bind-key -n M-Right select-pane -R | |
# C-a TAB == next pane. | |
bind-key Tab select-pane -t :.+ | |
# C-a ESC = copy mode | |
bind-key Escape copy-mode | |
# Better split commands | |
bind | split-window -h | |
bind - split-window -v | |
unbind '"' | |
unbind % | |
# Lock client with C-A,x (needs the vlock command) | |
set -g lock-command vlock | |
set -g lock-after-time 0 # Seconds; 0 = never | |
bind x lock-client | |
bind o set lock-after-time 300 \; display-message "Auto-lock enabled (5m)" | |
bind O set lock-after-time 0 \; display-message "Auto-lock disabled" | |
# Easy config reloads | |
bind R source-file ~/.tmux.conf \; display-message "Configuration reloaded" | |
# Start numbering at 1 | |
set -g base-index 1 | |
# Allows for faster key repetition | |
set -s escape-time 0 | |
# Allows inheriting SSH_AUTH_SOCK and others in case of re-attach. | |
# Only new sessions will get the new variables from outside tmux. | |
# For SSH_AUTH_SOCK, 'tm' creates a symlink to a fixed location. | |
set -g update-environment "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY" | |
# Status bar settings | |
# status line | |
set -g status-justify left | |
set -g status-bg colour8 | |
set -g status-fg colour15 | |
set -g status-left "" | |
set -g status-right "|#[fg=yellow]#S" | |
# messaging | |
set -g message-style fg=black,bg=yellow | |
set -g message-command-style fg=magenta,bg=black | |
# Rename window numbers after window close. | |
set -g renumber-windows on | |
# window status options. | |
setw -g window-status-format "#F#I #W" | |
setw -g window-status-current-format "#F#I #W" | |
setw -g window-status-current-style fg=colour15,bg=colour24 | |
setw -g window-status-style fg=colour15,bg=colour8 | |
# Allow change of window title with escape sequences. | |
setw -g allow-rename on | |
# Don't try to change the window title automatically (this is done by PROMPT_COMMAND) | |
setw -g automatic-rename off | |
# Rather than constraining window size to the maximum size of any client | |
# connected to the *session*, constrain window size to the maximum size of any | |
# client connected to *that window*. Much more reasonable. | |
setw -g aggressive-resize on | |
# Allows us to use C-a a <command> to send commands to a TMUX session inside | |
# another TMUX session | |
bind-key a send-prefix | |
# Change the terminal status, if possible. | |
set -g set-titles on | |
set -g set-titles-string "[#S] #(whoami)@#h: #W" | |
# Huge scrollback | |
set -g history-limit 15000 | |
# Force terminal type. | |
set -g default-terminal "tmux-256color" | |
# True color terminal overrides | |
# This matches a terminal *outside* tmux and enables truecolor support (Tc). | |
# Use tmux info | grep Tc to verify. | |
# | |
# More info at: https://gist.github.com/XVilka/8346728 | |
# Github issue: https://github.com/tmux/tmux/issues/34 | |
# In vim: set tgc=on may be required. | |
set-option -ga terminal-overrides ",*256col*:Tc" | |
set-option -ga terminal-overrides ",xterm:Tc" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment