# KEY BINDINGS # Adrien Luxey ########################### ### 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 ##################################################### # Vim Tmux Navigator # Smart pane switching with awareness of Vim splits. # See: https://github.com/christoomey/vim-tmux-navigator is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'" bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L' bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D' bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U' bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R' #tmux_version='$(tmux -V | sed -En "s/^tmux ([1-9]+(.[0-9]+)?).*/\1/p")' #if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \ # "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'" #if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \ # "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'" #bind-key -T copy-mode-vi 'C-h' select-pane -L #bind-key -T copy-mode-vi 'C-j' select-pane -D #bind-key -T copy-mode-vi 'C-k' select-pane -U #bind-key -T copy-mode-vi 'C-l' select-pane -R #bind-key -T copy-mode-vi 'C-m' select-pane -l # 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'