Added keystrokes listening toggle button for nested tmux sessions

This commit is contained in:
Adrien Luxey 2020-01-25 21:51:35 +01:00
parent 71087cf9ff
commit a785cec3c2

View file

@ -31,10 +31,10 @@ 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
# 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)
# 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
@ -44,6 +44,9 @@ set -g @plugin 'tmux-plugins/tmux-yank'
### 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"
@ -52,6 +55,28 @@ set -ga terminal-overrides ",*256col*:Tc"
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
#####################################################
# 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 ###