dotfiles/tmux.conf

133 lines
3.5 KiB
Plaintext

# KEY BINDINGS
# Alex Auvolat + Adrien Luxey additions
###########################
### Packages management ###
###########################
# Tmux Package Manager
# Prefix + I => Install plugins (after adding them to tmux.conf)
# Prefix + + Alt-u => uninstall
# Prefix + U => Update packages
set -g @plugin 'tmux-plugins/tpm'
# Tmux OneDark: http://github.com/odedlaz/tmux-onedark-themetheme
#set -g @plugin 'odedlaz/tmux-onedark-theme'
# Tmux-Themepack (feat Powerline)
set -g @plugin 'jimeh/tmux-themepack'
set -g @themepack 'powerline/default/blue'
# Save and restore Tmux sessions
# Prefix + Ctrl-s => Save current session
# Prefix + Ctrl-r => Restore
set -g @plugin 'tmux-plugins/tmux-resurrect'
# Continuous saving tmux environment (depends on Ressurect)
# Also auto-starts tmux on boot and auto-restores last session
set -g @plugin 'tmux-plugins/tmux-continuum'
#set -g status-right 'Continuum status: #{continuum_status}'
set -g @continuum-restore 'on' # Auto restore previous session
set -g @continuum-save-interval '15' # save time in minutes
# Copy to system clipboard
# Normal mode:
# Prefix + y => (yank) Copies text from command line to clipboard
# Copy mode:
# y => copy selection to clipboard
# Y => Put (copy a selection then paste it to cmd)
set -g @plugin 'tmux-plugins/tmux-yank'
# There seems to be cool things to make Vim and Tmux play well together too
#######################
### Adrien's stuff ###
#######################
# Set the display duration of message (in ms)
set-option -g display-time 2000
# Make tmux display true colors )
set -g default-terminal "xterm-256color"
set -ga terminal-overrides ",*256col*:Tc"
# Remember my path when splitting windows
bind % split-window -h -c '#{pane_current_path}' # Split panes horizontally
bind '"' split-window -v -c '#{pane_current_path}' # Split panes vertically
# A big-ass history
set -g history-limit 10000
# Fast key repetition with escape-time 0
set -g escape-time 0
#####################################################
# Simple nested tmux sessions (e.g. remote and local)
# F10 toggles tmux listening for keystrokes, allowing to switch betwen remote and local
# https://www.freecodecamp.org/news/tmux-in-practice-local-and-nested-remote-tmux-sessions-4f7ba5db8795/
bind -T root F10 \
set prefix None \;\
set key-table off \;\
display-message "Discarding keystrokes."\;\
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
refresh-client -S
bind -T off F10 \
set -u prefix \;\
set -u key-table \;\
display-message "Listening to keystrokes."\;\
refresh-client -S
#####################################################
# Notes :
# prefix ~ --> show-messages (see previous messages)
#####################
### Alex's stuff ###
#####################
setw -g mode-keys vi
# remap prefix to Control + a
set -g prefix C-q
unbind C-b
bind C-q send-prefix
unbind q
bind-key q copy-mode
unbind p
bind p paste-buffer
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
# quick pane cycling
unbind ^A
bind ^A select-pane -t :.+
# switch panes using vim-like bindings C-a hjkl
unbind h
unbind j
unbind k
unbind l
bind h select-pane -L
bind l select-pane -R
bind k select-pane -U
bind j select-pane -D
# switch windows using bindings C-q C-hl
unbind ^H
unbind ^L
bind ^H previous-window
bind ^L next-window
# OTHER OPTIONS
set -g mouse on
# don't rename windows automatically
set-option -g allow-rename off
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'