178 lines
5.2 KiB
Bash
178 lines
5.2 KiB
Bash
# 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'
|
|
|
|
# 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'
|
|
|
|
# Manage sessions, windows etc. with fzf
|
|
#set -g @plugin 'sainnhe/tmux-fzf'
|
|
|
|
# Opens stuff
|
|
#set -g @plugin 'tmux-plugins/tmux-open'
|
|
#set -g @open-S 'https://www.startpage.com/do/search?cat=web&cmd=process_search&language=english&engine0=v1all&abp=1&query='
|
|
#set -g @open 'C-f'
|
|
#set -g @open-editor 'C-e'
|
|
|
|
###########
|
|
# Theming #
|
|
###########
|
|
|
|
# Set current dir name as tab (window) name
|
|
# * Shows pwd #{b:pane_current_path}
|
|
# * Shows full path #{pane_current_path}
|
|
#path="#(if [[ $HOME == #{pane_current_path} ]]; then echo \"~\" ; else echo #{b:pane_current_path}; fi)"
|
|
#set -g status-interval 1
|
|
#set-window-option -g window-status-separator ""
|
|
#set-window-option -g window-status-current-format " #{b:pane_current_path} "
|
|
#set-window-option -g window-status-format " #{b:pane_current_path} "
|
|
|
|
|
|
# Tmux OneDark: http://github.com/odedlaz/tmux-onedark-themetheme
|
|
#set -g @plugin 'odedlaz/tmux-onedark-theme'
|
|
|
|
# Make tmux display true colors
|
|
#set -g default-terminal "screen-256color"
|
|
set -g default-terminal "xterm-256color"
|
|
# Creates a visual glitch with e.g. colored comments, don't use.
|
|
#set -ga terminal-overrides ",*256col*:Tc"
|
|
|
|
#set-option -g allow-rename off
|
|
|
|
########
|
|
# Misc #
|
|
########
|
|
|
|
set -g mouse on
|
|
|
|
# Home/End keys handled in [n]vim
|
|
bind-key -n Home send Escape "OH"
|
|
bind-key -n End send Escape "OF"
|
|
|
|
# Set the display duration of message (in ms)
|
|
set-option -g display-time 4000
|
|
|
|
# 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 50000
|
|
|
|
# Fast key repetition with escape-time 0
|
|
set -g escape-time 0
|
|
|
|
######################
|
|
# 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)
|
|
|
|
###################
|
|
# Nested sessions #
|
|
###################
|
|
|
|
# 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
|
|
|
|
################
|
|
# 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
|
|
|
|
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
|
|
run -b '~/.tmux/plugins/tpm/tpm'
|