Skip to content

Instantly share code, notes, and snippets.

@cvuillemez
Last active July 5, 2019 08:35
Show Gist options
  • Save cvuillemez/a8c4b732324fe145c8e776e442d284d4 to your computer and use it in GitHub Desktop.
Save cvuillemez/a8c4b732324fe145c8e776e442d284d4 to your computer and use it in GitHub Desktop.
TMUX configuration files (works well with Kitty)
# Automatically set window title
set-window-option -g automatic-rename on
set-window-option -g automatic-rename-format '#{host_short}'
set-option -g set-titles on
set-option -g set-titles-string '#{host_short}'
set -g default-terminal 'xterm-256color'
# Big history on screen
set -g history-limit 50000
# VI mode is prefered for me
set -g status-keys vi
setw -g mode-keys vi
# Disable to not interact with kitty
setw -g mouse off
setw -g monitor-activity on
# Horizontal split
bind-key v split-window -h
# Vertical split
bind-key s split-window -v
# Pane zoom
bind -n C-s resize-pane -Z
# Use CTRL-arrow keys without prefix key to resize pane
bind -n M-Down resize-pane -D
bind -n M-Up resize-pane -U
bind -n M-Left resize-pane -L
bind -n M-Right resize-pane -R
# Use Alt-arrow keys without prefix key to switch panes
bind -n S-Down select-pane -D
bind -n S-Up select-pane -U
bind -n S-Left select-pane -L
bind -n S-Right select-pane -R
# CRTL-arrow to switch windows
bind -n C-Left previous-window
bind -n C-Right next-window
# Shift-UP to switch layout
bind -n C-n next-layout
# CTRL-Space to enter in copy mode
bind -n C-Space copy-mode
# No delay for escape key press
set -sg escape-time 0
# Reload tmux config
bind r source-file ~/.tmux.conf
# Switch session
bind -n C-Up switch-client -n
bind -n C-Down switch-client -p
# THEME
# for colour codes see https://i.stack.imgur.com/e63et.png
set -g status-bg colour24
set -g status-fg colour52
# Since 2.9
#set -g window-status-current-bg red
#set -g window-status-current-fg green
#set -g window-status-current-attr bold
set -g window-status-current-style bg=red,fg=green,bold
set -g status-interval 10
set -g status-left-length 30
set -g status-left '#[fg=black](#S)'
set -g status-right '#[fg=black]#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=black]%H:%M#[default]'
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
# restoring pane content
set -g @resurrect-capture-pane-contents 'on'
# restoring shell history
set -g @resurrect-save-shell-history 'on'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'
new-session -A -s "NEW_SESSION"
new-window -a -t:{end} -n "NEW_WINDOW" 'ssh -t host001 "unset TMOUT;bash"'
split-window -v 'ssh -t host002 "unset TMOUT;bash"'
split-window -h 'ssh -t host003 "unset TMOUT;bash"'
split-window -v 'ssh -t host004 "unset TMOUT;bash"'
split-window -h 'ssh -t host005 "unset TMOUT;bash"'
select-layout even-horizontal
split-window -v 'ssh -t host006 "unset TMOUT;bash"'
split-window -h 'ssh -t host007 "unset TMOUT;bash"'
split-window -v 'ssh -t host008 "unset TMOUT;bash"'
split-window -h 'ssh -t host009 "unset TMOUT;bash"'
split-window -v 'ssh -t host010 "unset TMOUT;bash"'
select-layout main-horizontal
setw synchronize-panes
export TERM=xterm-256color
export HISTCONTROL=ignoredups
export HISTSIZE=10000
alias ll="ls -la --color"
alias togglefullscreen="wmctrl -r :ACTIVE: -b toggle,fullscreen"
ssh ()
{
if [[ "$(ps -p $(ps -p $$ -o ppid=) -o comm=)" =~ "tmux" ]]; then
tmux rename-window "$(echo $* | cut -c-10)";
command ssh -t "$@" "unset TMOUT;bash";
tmux set-window-option automatic-rename "on" > /dev/null;
else
command ssh -t "$@" "unset TMOUT;bash";
fi
}
@elmchaouki
Copy link

Thanks so much

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