Skip to content

Instantly share code, notes, and snippets.

@jsvazic
Last active March 10, 2022 15:27
Show Gist options
  • Save jsvazic/199fdf8819fb6fe6a4ea1ad7fdfb21dc to your computer and use it in GitHub Desktop.
Save jsvazic/199fdf8819fb6fe6a4ea1ad7fdfb21dc to your computer and use it in GitHub Desktop.
My .tmux.conf file
# Set prefix to Ctrl-a
set-option -g prefix C-a
unbind C-a
bind-key C-a send-prefix
# Use Alt-arrow keys to switch panes
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Use Shift-arrow to switch windows
bind -n S-Left previous-window
bind -n S-Right next-window
# vi mode
set-window-option -g mode-keys vi
# Mouse mode
set -g mouse on
# Set easier window split keys
bind-key v split-window -h -c "#{pane_current_path}"
bind-key h split-window -v -c "#{pane_current_path}"
bind-key c new-window -c "#{pane_current_path}"
# Easier config reload
bind-key r source-file ~/.tmux.conf \; display-message "tmux.conf reloaded."
# Lots of history
set-option -g history-limit 10000
# Status bar settings
set-option -g status on
set-option -g status-interval 2
set-option -g status-right-length 50
set -g status-right "#([ -d /proc/sys/net/ipv4/conf/tun0 ] && echo \"$({ ip -4 -br a sh dev tun0 | awk {'print $3'} | cut -f1 -d/; } 2>/dev/null) 🬄 \")#{pane_width}x#{pane_height} 🬄 %a %Y-%m-%d %H:%M"
@jsvazic
Copy link
Author

jsvazic commented Mar 30, 2018

After the TERM setting, add this to .bashrc:

if command -v tmux>/dev/null; then
    [[ ! $TERM =~ screen ]] && [ -z $TMUX ] && exec tmux
fi

This will start tmux automatically when a terminal is created.

@jsvazic
Copy link
Author

jsvazic commented Apr 3, 2018

Added the pane dimensions to the right status bar settings to make things easier when determining dimensions to set for PTTY sessions, etc.

@jsvazic
Copy link
Author

jsvazic commented Apr 16, 2018

Added a decent history-limit setting and adjusted the status-right-length to something reasonable.

@jsvazic
Copy link
Author

jsvazic commented Sep 26, 2018

Added vi mode for easier selecting of text for large blocks.

@jsvazic
Copy link
Author

jsvazic commented May 15, 2020

Added code to change the background colour of panes that are not in focus, to better indicate what's currently in use.

@jsvazic
Copy link
Author

jsvazic commented Feb 14, 2021

Removed the lines for background colours as they didn't work, and added some config setup to keep the current path when splitting panes or creating new windows.

@jsvazic
Copy link
Author

jsvazic commented Mar 10, 2022

Updated the status bar to include some separators as well as the IP for a tun0 interface, i.e. VPN for TryHackMe, etc.

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