From e5e30d079a34f2316854bc7da8919699fd803169 Mon Sep 17 00:00:00 2001 From: EoF Date: Thu, 19 Sep 2019 18:57:29 +0500 Subject: [PATCH] =?UTF-8?q?=D0=90=D0=B2=D1=82=D0=BE=D0=BC=D0=B0=D1=82?= =?UTF-8?q?=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=BE=D0=B5=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=BC=D0=B5=D1=89=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D1=82=D1=83=D1=81-=D0=B1=D0=B0=D1=80=D0=B0=20=D0=B2=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B2=D0=B8=D1=81=D0=B8=D0=BC=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D0=B8=20=D0=BE=D1=82=20=D1=82=D0=B8=D0=BF=D0=B0=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 4 ++-- tmux/remote.conf | 10 ---------- tmux/{local.conf => tmux.conf} | 10 ++-------- tmux/utils/session-type.sh | 7 ------- tmux/utils/status-switch.sh | 20 ++++++++++++++++++++ 5 files changed, 24 insertions(+), 27 deletions(-) delete mode 100644 tmux/remote.conf rename tmux/{local.conf => tmux.conf} (96%) delete mode 100644 tmux/utils/session-type.sh create mode 100755 tmux/utils/status-switch.sh diff --git a/install.sh b/install.sh index d8fea29..b1c95ae 100755 --- a/install.sh +++ b/install.sh @@ -4,7 +4,7 @@ set -e # Backup existing configs if [ -e "$HOME/.tmux.conf" ]; then - printf "Found existing .tmux.conf in your \$HOME directory. Will create a backup at $HOME/.tmux.conf.bak\n" + printf "Found existing .tmux.conf in your \$HOME directory. Will create a backup at $HOME/.tmux.conf.bak\n" fi cp -f "$HOME/.tmux.conf" "$HOME/.tmux.conf.bak" 2>/dev/null || true @@ -22,7 +22,7 @@ fi cp -f "$HOME/.vimrc" "$HOME/.vimrc.bak" 2>/dev/null || true # Create symlinks -ln -sf .dots/tmux/local.conf "$HOME"/.tmux.conf +ln -sf .dots/tmux/tmux.conf "$HOME"/.tmux.conf ln -sf .dots/zsh/zshrc "$HOME"/.zshrc ln -sf .dots/vim/vimrc "$HOME"/.vimrc diff --git a/tmux/remote.conf b/tmux/remote.conf deleted file mode 100644 index ea385bc..0000000 --- a/tmux/remote.conf +++ /dev/null @@ -1,10 +0,0 @@ -# show status bar at bottom for remote session, -# so it do not stack together with local session's one -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 "$wg_session" -set -g status-right "#{prefix_highlight} $wg_is_keys_off $wg_is_zoomed #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_user_host | #{online_status}" diff --git a/tmux/local.conf b/tmux/tmux.conf similarity index 96% rename from tmux/local.conf rename to tmux/tmux.conf index 87cd7a9..77e820c 100644 --- a/tmux/local.conf +++ b/tmux/tmux.conf @@ -310,14 +310,8 @@ set -g @open-S 'https://www.google.com/search?q=' # ============================================== # Session is considered to be remote when we ssh into host -#if-shell 'test -n "$SSH_CLIENT"' \ -# 'source-file ~/.dots/tmux/remote.conf' - -#set-hook -g session-created "if-shell 'test -n \"$SSH_CONNECTION\"' 'set status-position bottom' 'set -u status-position'" -#set-hook -g client-attached "if-shell 'test -n \"$SSH_CONNECTION\"' 'set status-position bottom' 'set -u status-position'" - -set-hook -g client-attached 'run ~/.dots/tmux/utils/session-type.sh' -set-hook -g session-created 'run ~/.dots/tmux/utils/session-type.sh' +set-hook -g client-attached 'run ~/.dots/tmux/utils/status-switch.sh' +set-hook -g session-created 'run ~/.dots/tmux/utils/status-switch.sh' # 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 diff --git a/tmux/utils/session-type.sh b/tmux/utils/session-type.sh deleted file mode 100644 index 6a73fdc..0000000 --- a/tmux/utils/session-type.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -if [ -n "$SSH_CONNECTION" ]; then - tmux set status-position bottom -else - tmux set -u status-position -fi \ No newline at end of file diff --git a/tmux/utils/status-switch.sh b/tmux/utils/status-switch.sh new file mode 100755 index 0000000..c4d216d --- /dev/null +++ b/tmux/utils/status-switch.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# Determine current session type - remote or local +if [ -n "$SSH_CONNECTION" ]; then + # Show status bar at bottom for remote session, + # so it do not stack together with local session's one + tmux set status-position bottom + + # In remote mode we don't show "clock" and "battery status" widgets + set status-left "$wg_session" + set status-right "#{prefix_highlight} $wg_is_keys_off $wg_is_zoomed #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_user_host | #{online_status}" + + # 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 +else + # Just unset session-variables for local session + tmux set -u status-position + tmux set -u status-left + tmux set -u status-right +fi