Skip to content

Instantly share code, notes, and snippets.

@saveman71
Created February 14, 2022 13:46
Show Gist options
  • Save saveman71/5b59bba8ee433ce8008b6874deb3d812 to your computer and use it in GitHub Desktop.
Save saveman71/5b59bba8ee433ce8008b6874deb3d812 to your computer and use it in GitHub Desktop.
# Change prefix key to Ctrl+a
unbind C-b
set -g prefix C-q
## FIX for termnator mouse bugs
## see https://superuser.com/questions/417027/why-are-random-characters-inserted-into-my-tmux-session
#set -g mouse-utf8 off
## set the default TERM
set -g default-terminal "screen"
## update the TERM variable of terminal emulator when creating a new session or attaching a existing session
set -g update-environment 'DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY TERM'
## determine if we should enable 256-colour support
if "[[ ${TERM} =~ 256color || ${TERM} == fbterm ]]" 'set -g default-terminal screen-256color'
# Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 1
# Copy mode
unbind [
bind Escape copy-mode
# Use Vi mode
setw -g mode-keys vi
# Make mouse useful in copy mode
#setw -g mode-mouse on
#set -g mouse-select-pane on
#set -g mouse-select-window on
# For the following lines, see https://www.reddit.com/r/tmux/comments/3paqoi/tmux_21_has_been_released/cw552qd
set-option -g -q mouse on
bind-key -T root PPage if-shell -F "#{alternate_on}" "send-keys PPage" "copy-mode -e; send-keys PPage"
# bind-key -t vi-copy PPage page-up
# bind-key -t vi-copy NPage page-down
bind-key -T root WheelUpPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M"
bind-key -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M"
# bind-key -t vi-copy WheelUpPane halfpage-up
# bind-key -t vi-copy WheelDownPane halfpage-down
# More straight forward key bindings for splitting
unbind %
bind | split-window -h -c "#{pane_current_path}"
bind v split-window -h -c "#{pane_current_path}"
unbind '"'
bind - split-window -v -c "#{pane_current_path}"
bind h split-window -v -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# History
set -g history-limit 10000
# Pane
unbind o
bind C-s select-pane -t :.-
# Terminal emulator window title
set -g set-titles on
set -g set-titles-string '#S:#I.#P #W'
# =====================================
# === Theme ===
# =====================================
# Feel free to NOT use this variables at all (remove, rename)
# this are named colors, just for convenience
color_orange="colour166" # 208, 166
color_purple="colour134" # 135, 134
color_green="colour076" # 070
color_blue="colour39"
color_yellow="colour220"
color_red="colour160"
color_black="colour232"
color_white="white" # 015
# This is a theme CONTRACT, you are required to define variables below
# Change values, but not remove/rename variables itself
color_dark="$color_black"
color_light="$color_white"
color_session_text="$color_blue"
color_status_text="colour245"
color_main="$color_orange"
color_secondary="$color_purple"
color_level_ok="$color_green"
color_level_warn="$color_yellow"
color_level_stress="$color_red"
color_window_off_indicator="colour088"
color_window_off_status_bg="colour238"
color_window_off_status_current_bg="colour254"
# https://medium.freecodecamp.org/tmux-in-practice-local-and-nested-remote-tmux-sessions-4f7ba5db8795
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]"
# Status Bar
set -g status-style bg=default,fg=white
set -g status-interval 1
set -g status-left '#[fg=colour117]#H#[default] '
set -g status-right "$wg_is_keys_off #[fg=yellow]#(cut -d ' ' -f 1-3 /proc/loadavg)#[default] #[fg=colour117,bold]%H:%M:%S#[default]"
# set -g status-right "$wg_is_keys_off #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_user_host"
# Notifying if other windows has activities
setw -g monitor-activity on
set -g visual-activity on
# Highlighting the active window in status bar
setw -g window-status-current-style bg=colour117,fg=black
set -g window-style ''
set -g window-active-style ''
# Clock
setw -g clock-mode-colour colour117
setw -g clock-mode-style 24
# Pane border
set -g pane-border-style bg=default,fg=colour240
# Active pane border
set -g pane-active-border-style bg=default,fg=colour117
# Pane number indicator
set -g display-panes-colour colour233
set -g display-panes-active-colour colour245
set -g pane-border-status top
# Enable xterm keys (ctrl arrow for moving the cursor by a whole word)
set-window-option -g xterm-keys on
unbind C-Up
unbind C-Down
unbind C-Left
unbind C-Right
# Use Alt-arrow keys without prefix key 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
# Reload tmux config
bind r source-file ~/.tmux.conf
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# My plugins:
#set -g @plugin 'tmux-plugins/tmux-resurrect'
#set -g @resurrect-processes '\
# "~yarn run \"dev-https\" ->" \
# "~yarn run \"dev-https\"->" \
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment