[tmux] Add remote session nesting
If calling a tmux session within a tmux session, pressing F12 will toggle between sending commands to the outer or inner session. If the outer session is inactive its status-bar will be slightly greyed out to show that no commands will reach it. If the inner session is a remote ssh session, it will set some additional stylings for the status-bar to further differentiate the two.
This commit is contained in:
parent
c8cd9bf11e
commit
7fab7dd6fb
4 changed files with 95 additions and 11 deletions
|
|
@ -157,3 +157,38 @@ set -g status-left "#[fg=#c8c8c8,bg=#2e2e2e] #S #[fg=#2e2e2e,bg=#2e2e2e,nobold,n
|
|||
set -g status-right "#[fg=#2e2e2e,bg=#2e2e2e,nobold,nounderscore,noitalics]#{prefix_highlight} #[fg=#c8c8c8,bg=#2e2e2e] %H:%M:%S #[fg=#2e2e2e,bg=#2e2e2e,nobold,nounderscore,noitalics]#[fg=#c8c8c8,bg=#2e2e2e] %d-%b-%y #[fg=#2e2e2e,bg=#2e2e2e,nobold,nounderscore,noitalics]#[fg=#c8c8c8,bg=#2e2e2e] #H "
|
||||
setw -g window-status-format "#[fg=#2e2e2e,bg=#2e2e2e,nobold,nounderscore,noitalics]#[default] #I #W #[fg=#2e2e2e,bg=#2e2e2e,nobold,nounderscore,noitalics]"
|
||||
setw -g window-status-current-format "#[fg=#2e2e2e,bg=#2e2e2e,nobold,nounderscore,noitalics]#[fg=#c8c8c8,bg=#2e2e2e] #I #W #[fg=#2e2e2e,bg=#2e2e2e,nobold,nounderscore,noitalics]"
|
||||
|
||||
########################
|
||||
## 5. Nested Sessions ##
|
||||
########################
|
||||
# from: https://github.com/samoshkin/tmux-config/blob/master/tmux/tmux.conf
|
||||
# all credit to samoshkin
|
||||
|
||||
# Session is considered to be remote when we ssh into host
|
||||
if-shell 'test -n "$SSH_CLIENT"' \
|
||||
'source-file $XDG_CONFIG_HOME/tmux/tmux.remote.conf'
|
||||
|
||||
# We want to have single prefix key "C-a", usable both for local and remote session
|
||||
# we don't want to "C-a" + "a" approach either
|
||||
# Idea is to turn off all key bindings and prefix handling on local session,
|
||||
# so that all keystrokes are passed to inner/remote session
|
||||
|
||||
# see: toggle on/off all keybindings · Issue #237 · tmux/tmux - https://github.com/tmux/tmux/issues/237
|
||||
|
||||
# Also, change some visual styles when window keys are off
|
||||
bind -T root F12 \
|
||||
set prefix None \;\
|
||||
set key-table off \;\
|
||||
set status-style fg="colour245",bg="colour238" \;\
|
||||
set window-status-current-format "#[fg=$color_window_off_status_bg,bg=$color_window_off_status_current_bg]$separator_powerline_right#[default] #I:#W# #[fg=$color_window_off_status_current_bg,bg=$color_window_off_status_bg]$separator_powerline_right#[default]" \;\
|
||||
set window-status-current-style fg="colour232",bg="colour254","bold" \;\
|
||||
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
|
||||
refresh-client -S \;\
|
||||
|
||||
bind -T off F12 \
|
||||
set -u prefix \;\
|
||||
set -u key-table \;\
|
||||
set -u status-style \;\
|
||||
set -u window-status-current-style \;\
|
||||
set -u window-status-current-format \;\
|
||||
refresh-client -S
|
||||
|
|
|
|||
10
.config/tmux/tmux.remote.conf
Normal file
10
.config/tmux/tmux.remote.conf
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# show status bar at bottom for remote session,
|
||||
set -g status-position bottom
|
||||
|
||||
# Set port of SSH remote tunnel, where tmux will pipe buffers to transfer on local machine for copy
|
||||
set -g @copy_backend_remote_tunnel_port 11988
|
||||
|
||||
# In remote mode we don't show "clock" and "battery status" widgets
|
||||
set -g status-left "#[fg=#c8c8c8,bg=#2e2e2e][SSH]#S #[fg=#2e2e2e,bg=#2e2e2e,nobold,nounderscore,noitalics]#[fg=#c8c8c8,bg=#2e2e2e] #(whoami) #[fg=#2e2e2e,bg=#2e2e2e,nobold,nounderscore,noitalics]#[fg=#c8c8c8,bg=#2e2e2e] #I:#P #[fg=#2e2e2e,bg=#2e2e2e,nobold,nounderscore,noitalics]"
|
||||
set -g status-right "#{prefix_highlight} $wg_is_keys_off $wg_is_zoomed #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_user_host | #{online_status}"
|
||||
set -g status-right "#[fg=#2e2e2e,bg=#2e2e2e,nobold,nounderscore,noitalics]#{prefix_highlight} #H "
|
||||
Loading…
Add table
Add a link
Reference in a new issue