Skip to content

Instantly share code, notes, and snippets.

@Fi3
Forked from paulodeleo/.tmux.conf
Last active January 3, 2024 13:31
Show Gist options
  • Save Fi3/f305074509d4f44ee82e175ed830f546 to your computer and use it in GitHub Desktop.
Save Fi3/f305074509d4f44ee82e175ed830f546 to your computer and use it in GitHub Desktop.
Tmux configuration to enable mouse scroll and mouse panel select, taken from: http://brainscraps.wikia.com/wiki/Extreme_Multitasking_with_tmux_and_PuTTY
# Scroll History
set -g history-limit 50000
# Set ability to capture on start and restore on exit window data when running an application
setw -g alternate-screen on
# Scroll with mouse
setw -g mouse on
# Lower escape timing from 500ms to 50ms for quicker response to scroll-buffer access.
set -s escape-time 0
# Increase tmux messages display duration from 750ms to 4s
set -g display-time 4000
# Refresh 'status-left' and 'status-right' more often, from every 15s to 5s
set -g status-interval 5
# Focus events enabled for terminals that support them
set -g focus-events on
# Status bar customization
set -g status-bg black
set -g status-fg white
set -g status-interval 5
set -g status-left-length 90
set -g status-right-length 60
set -g status-left '#[fg=Green]#(whoami)#[fg=white]::#[fg=blue]#(hostname - s)#[fg=white]::##[fg=yellow]#(curl ipecho.net/plain;echo)'
set -g status-justify left
set -g status-right '#[fg=Cyan]#S #[fg=white]%a %d %b %R'
# True Colors
set -g default-terminal 'alacritty'
set -ga terminal-overrides ',alacritty:RGB'
# Set reload key to r
bind r source-file ~/.tmux.conf
# Count sessions start at 1
set -g base-index 1
# Set XTerm key bindings
setw -g xterm-keys on
# Use vim bindings
setw -g mode-keys vi
# Remap window navigation to vim
unbind-key j
bind-key j select-pane -D
unbind-key k
bind-key k select-pane -U
unbind-key h
bind-key h select-pane -L
unbind-key l
bind-key l select-pane -R
# Remap copy and paste to vim
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
# use y to copy the last buffer in tmux clipboard to linux clipboard (need xclip installed)
bind y run-shell "tmux show-buffer | xclip -sel clip -i" \; display-message "Copied tmux buffer to system clipboard"
# Set the title bar
set -g set-titles on
set -g set-titles-string '#(whoami) :: #h :: #(curl ipecho.net/plain;echo)'
# don't rename windows automatically
set-option -g allow-rename off
# Use f12 to disable outer session when work with nested session. The below shouldn't be in the remote conf
bind -T root F12 \
set prefix None \;\
set key-table off \;\
set status-style "fg=$color_status_text,bg=$color_window_off_status_bg" \;\
set window-status-current-format "#[fg=$color_window_off_status_bg,bg=$color_window_off_status_current_bg]$separator_powerline_right#[default] #I:#W# #[fg=$color_window_off_status_current_bg,bg=$color_window_off_status_bg]$separator_powerline_right#[default]" \;\
set window-status-current-style "fg=$color_dark,bold,bg=$color_window_off_status_current_bg" \;\
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
refresh-client -S \;\
bind -T off F12 \
set -u prefix \;\
set -u key-table \;\
set -u status-style \;\
set -u window-status-current-style \;\
set -u window-status-current-format \;\
refresh-client -S
wg_is_keys_off="#[fg=$color_light,bg=$color_window_off_indicator]#([ $(tmux show-option -qv key-table) = 'off' ] && echo 'OFF')#[default]"
set -g status-right "$wg_is_keys_off #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_user_host"
# Set history
set -g history-file ~/.tmux_history
# Copy the tmux buffer on the system clipboard automatically
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-capture-pane-contents 'on'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin '[email protected]/user/plugin'
# set -g @plugin '[email protected]/user/plugin'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
# IMPORTANT!!!!! do `prefix + I` after open tmux for install plugin
# IMPORTANT!!!!! do `git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm` before open tmux
run '~/.tmux/plugins/tpm/tpm'
Terminal -> Bell -> Action to happen when a bell occurs = None (bell disabled)
Window -> Lines of Scrollback = 1000 (For the quick "Oops, what did I do" moment)
Window -> Reset scrollback on keypress = check
Window -> Reset scrollback on display activity = uncheck
SSH -> Remote command = tmux a -t base || tmux new -s base (if you're going to use this connection for tmux)
SSH -> Protocol = 2 only
SSH -> Auth -> Attempt authentication using Pageant = check (Most Important One)
SSH -> Auth -> Private key file for authentication = c:\full\path\to\rsa.ppk
SSH -> X11 -> Enable X11 forwarding = check (Important if you use X11 applications that need to display to your laptop.)
(copy/paste with mouse in putty should be done holding shift key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment