mirror of
https://github.com/samoshkin/tmux-config.git
synced 2026-01-04 00:38:01 +00:00
Add support for nested local and remote sessions. Multiple config tweaks
This commit is contained in:
@@ -32,6 +32,7 @@ rsync -aq ./tmux/ "$HOME"/.tmux
|
||||
|
||||
ln -sf --backup --suffix=.bak .tmux/tmux.conf "$HOME"/.tmux.conf;
|
||||
|
||||
# BUG: Fix for fresh installation
|
||||
"$HOME"/.tmux/plugins/tpm/bin/install_plugins
|
||||
|
||||
printf "$(tput setaf 2)OK:$(tput sgr0) Completed\n"
|
||||
|
||||
Submodule plugins/sysstat updated: 21a3fd61b4...335997c678
@@ -1,27 +0,0 @@
|
||||
|
||||
# =====================================
|
||||
# === Theme ===
|
||||
# =====================================
|
||||
|
||||
# Feel free to NOT use this variables at all (remove, rename)
|
||||
# this are named colors, just for convenience
|
||||
color_orange="colour166" # 208, 166
|
||||
color_purple="colour134" # 135, 134
|
||||
color_green="colour076" # 070
|
||||
color_blue="colour39"
|
||||
color_yellow="colour220"
|
||||
color_red="colour160"
|
||||
color_black="colour232"
|
||||
color_white="white" # 015
|
||||
|
||||
# This is a theme CONTRACT, you are required to define variables below
|
||||
# Change values, but not remove/rename variables itself
|
||||
color_dark="$color_black"
|
||||
color_light="$color_white"
|
||||
color_session_text="$color_blue"
|
||||
color_status_text="colour245"
|
||||
color_main="$color_orange"
|
||||
color_secondary="$color_purple"
|
||||
color_level_good="$color_green"
|
||||
color_level_warn="$color_yellow"
|
||||
color_lelel_achtung="$color_red"
|
||||
108
tmux/tmux.conf
108
tmux/tmux.conf
@@ -2,17 +2,17 @@
|
||||
# === General settings ===
|
||||
# ==========================
|
||||
|
||||
set -g default-terminal "screen-256color"
|
||||
set -g history-limit 20000
|
||||
set -g buffer-limit 20
|
||||
set -sg escape-time 1
|
||||
set -g display-time 2000
|
||||
set -g allow-rename off
|
||||
set -g default-terminal "screen"
|
||||
set -sg escape-time 0
|
||||
set -g display-time 1500
|
||||
set -g remain-on-exit off
|
||||
|
||||
# aggressive-resize [on | off]
|
||||
# alternate-screen [on | off]
|
||||
|
||||
set -g set-titles off
|
||||
set -g repeat-time 300
|
||||
setw -g allow-rename off
|
||||
setw -g automatic-rename off
|
||||
setw -g aggressive-resize on
|
||||
|
||||
# Change prefix key to C-a, easier to type, same to "screen"
|
||||
unbind C-b
|
||||
@@ -34,8 +34,11 @@ set -g mouse on
|
||||
# === Key bindings ===
|
||||
# ==========================
|
||||
|
||||
# Edit configuration and reload
|
||||
bind C-e new-window -n 'tmux.conf' "sh -c '\${EDITOR:-vim} ~/.tmux.conf && tmux source ~/.tmux.conf && tmux display \"Config reloaded\"'"
|
||||
|
||||
# Reload tmux configuration
|
||||
bind C-r source-file ~/.tmux.conf \; display "Reloaded"
|
||||
bind C-r source-file ~/.tmux.conf \; display "Config reloaded"
|
||||
|
||||
# Rename session and window
|
||||
unbind "\$"
|
||||
@@ -98,6 +101,8 @@ bind D if -F '#{session_many_attached}' \
|
||||
'confirm-before -p "Detach other clients? (y/n)" "detach -a"' \
|
||||
'display "Session has only 1 client attached"'
|
||||
|
||||
# Hide status bar on demand
|
||||
bind C-s if -F '#{s/off//:status}' 'set status off' 'set status on'
|
||||
|
||||
# ==================================================
|
||||
# === Window monitoring for activity and silence ===
|
||||
@@ -127,8 +132,8 @@ unbind ] # paste-buffer
|
||||
# Prefer vi style key table
|
||||
setw -g mode-keys vi
|
||||
|
||||
# trigger copy mode by pressing PageUp key w/o prepending it with prefix key
|
||||
bind -n PageUp copy-mode
|
||||
# trigger copy mode by
|
||||
bind PageUp copy-mode
|
||||
bind Escape copy-mode
|
||||
|
||||
bind p paste-buffer
|
||||
@@ -152,13 +157,40 @@ unbind -T copy-mode-vi MouseDragEnd1Pane
|
||||
bind -T copy-mode-vi MouseDown1Pane select-pane \; send-keys -X copy-selection
|
||||
|
||||
|
||||
# =====================================
|
||||
# === Theme ===
|
||||
# =====================================
|
||||
|
||||
# Feel free to NOT use this variables at all (remove, rename)
|
||||
# this are named colors, just for convenience
|
||||
color_orange="colour166" # 208, 166
|
||||
color_purple="colour134" # 135, 134
|
||||
color_green="colour076" # 070
|
||||
color_blue="colour39"
|
||||
color_yellow="colour220"
|
||||
color_red="colour160"
|
||||
color_black="colour232"
|
||||
color_white="white" # 015
|
||||
|
||||
# This is a theme CONTRACT, you are required to define variables below
|
||||
# Change values, but not remove/rename variables itself
|
||||
color_dark="$color_black"
|
||||
color_light="$color_white"
|
||||
color_session_text="$color_blue"
|
||||
color_status_text="colour245"
|
||||
color_main="$color_orange"
|
||||
color_secondary="$color_purple"
|
||||
color_level_good="$color_green"
|
||||
color_level_warn="$color_yellow"
|
||||
color_lelel_achtung="$color_red"
|
||||
color_window_off_indicator="colour088"
|
||||
color_window_off_status_bg="colour238"
|
||||
color_window_off_status_current_bg="colour254"
|
||||
|
||||
# =====================================
|
||||
# === Appearence and status bar ===
|
||||
# ======================================
|
||||
|
||||
# Load theme
|
||||
source ~/.tmux/theme.conf
|
||||
|
||||
set -g mode-style "fg=default,bg=$color_main"
|
||||
|
||||
# command line style
|
||||
@@ -172,13 +204,13 @@ set -g window-status-separator ""
|
||||
separator_powerline_left=""
|
||||
separator_powerline_right=""
|
||||
|
||||
setw -g window-status-style "fg=$color_status_text,bg=$color_dark"
|
||||
# setw -g window-status-style "fg=$color_status_text,bg=$color_dark"
|
||||
setw -g window-status-format " #I:#W "
|
||||
setw -g window-status-current-style "fg=$color_light,bold,bg=$color_main"
|
||||
setw -g window-status-current-format "#[fg=$color_dark,bg=$color_main]$separator_powerline_right#[default] #I:#W# #[fg=$color_main,bg=$color_dark]$separator_powerline_right#[default]"
|
||||
|
||||
# when window has monitoring notification
|
||||
setw -g window-status-activity-style "fg=$color_main,bg=$color_dark"
|
||||
setw -g window-status-activity-style "fg=$color_main"
|
||||
|
||||
# outline for active pane
|
||||
setw -g pane-active-border-style "fg=$color_main"
|
||||
@@ -188,18 +220,19 @@ set -g status on
|
||||
set -g status-interval 5
|
||||
set -g status-position top
|
||||
set -g status-justify left
|
||||
set -g status-right-length 140
|
||||
set -g status-right-length 100
|
||||
|
||||
# define widgets we're going to use in status bar
|
||||
# note, that this is not the complete list, some of them are loaded from plugins
|
||||
wg_session="#[fg=$color_session_text] #S #[default]"
|
||||
wg_battery="#{battery_status_fg} #{battery_icon} #{battery_percentage}"
|
||||
wg_date="#[fg=$color_secondary]%h %d %H:%M#[default]"
|
||||
wg_host="#[fg=$color_secondary]#(echo $USER)#[default]@#H"
|
||||
wg_user_host="💻 #[fg=$color_secondary]#(echo $USER)#[default]@#H"
|
||||
wg_is_zoomed="#[fg=$color_dark,bg=$color_secondary]#{?window_zoomed_flag,[Z],}#[default]"
|
||||
wg_is_keys_off="#[fg=$color_light,bg=$color_window_off_indicator]#([ $(tmux show-option -qv \"key-table\") == \"off\" ] && echo \"[OFF]\")#[default]"
|
||||
|
||||
set -g status-left "$wg_session"
|
||||
set -g status-right "#{prefix_highlight} $wg_is_zoomed #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_host | $wg_date $wg_battery #{online_status}"
|
||||
set -g status-right "#{prefix_highlight} $wg_is_keys_off $wg_is_zoomed #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_user_host | $wg_date $wg_battery #{online_status}"
|
||||
|
||||
# online and offline icon for tmux-online-status
|
||||
set -g @online_icon "#[fg=$color_level_good]●#[default]"
|
||||
@@ -207,7 +240,7 @@ set -g @offline_icon "#[fg=$color_level_achtung]●#[default]"
|
||||
|
||||
# Configure view templates for tmux-plugin-sysstat "MEM" and "CPU" widget
|
||||
set -g @sysstat_mem_size_unit "G"
|
||||
set -g @sysstat_mem_view_tmpl '#[fg=#{mem.color}]MEM:#{mem.pused}#[default] (#{mem.used})'
|
||||
set -g @sysstat_mem_view_tmpl '#[fg=#{mem.color}]MEM:#{mem.pused}#[default] #{mem.used}'
|
||||
set -g @sysstat_cpu_view_tmpl '#[fg=#{cpu.color}]CPU:#{cpu.pused}#[default]'
|
||||
|
||||
# Configure colors for tmux-plugin-sysstat "MEM" and "CPU" widget
|
||||
@@ -260,5 +293,40 @@ set -g @sidebar-tree-command 'tree -C'
|
||||
|
||||
set -g @open-S 'https://www.google.com/search?q='
|
||||
|
||||
|
||||
# ==============================================
|
||||
# === Nesting local and remote sessions ===
|
||||
# ==============================================
|
||||
|
||||
# Session is considered to be remote when we ssh into host
|
||||
if-shell 'test -n "$SSH_CLIENT"' \
|
||||
'source-file ~/.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=$color_status_text,bg=$color_window_off_status_bg" \;\
|
||||
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=$color_dark,bold,bg=$color_window_off_status_current_bg" \;\
|
||||
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
|
||||
|
||||
|
||||
# Run all plugins' scripts
|
||||
run '~/.tmux/plugins/tpm/tpm'
|
||||
|
||||
7
tmux/tmux.remote.conf
Normal file
7
tmux/tmux.remote.conf
Normal file
@@ -0,0 +1,7 @@
|
||||
# show status bar at bottom for remote session,
|
||||
# so it do not stack together with local session's one
|
||||
set -g status-position bottom
|
||||
|
||||
# In remote mode we don't show "clock" and "battery status" widgets
|
||||
set -g status-left "$wg_session"
|
||||
set -g status-right "#{prefix_highlight} $wg_is_tunneled $wg_is_zoomed #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_user_host | #{online_status}"
|
||||
Reference in New Issue
Block a user