From 1469d465f8ca754fc6bb0313a4886aa1c31535bc Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Fri, 12 Jan 2024 13:50:41 +0100 Subject: [PATCH] added support for defining TPM plugins with 'set -g @tpm_plugins', resolves #706 --- .tmux.conf | 32 ++++++++++++++++---------------- .tmux.conf.local | 3 +++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index f283d9b..ca40bd8 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1469,10 +1469,11 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # } # # __apply_plugins() { -# window_active="$1" -# tmux_conf_update_plugins_on_launch="$2" -# tmux_conf_update_plugins_on_reload="$3" -# tmux_conf_uninstall_plugins_on_reload="$4" +# TMUX_PLUGIN_MANAGER_PATH="$1" +# window_active="$2" +# tmux_conf_update_plugins_on_launch="$3" +# tmux_conf_update_plugins_on_reload="$4" +# tmux_conf_uninstall_plugins_on_reload="$5" # # if [ -z "$TMUX_PLUGIN_MANAGER_PATH" ]; then # return 255 @@ -1483,15 +1484,18 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # if [ -z "$(tmux show -gv '@plugin' 2>/dev/null)" ] && [ -z "$tpm_plugins" ]; then # if _is_true "$tmux_conf_uninstall_plugins_on_reload" && [ -d "$TMUX_PLUGIN_MANAGER_PATH/tpm" ]; then # tmux display 'Uninstalling tpm and plugins...' +# tmux set-environment -gu TMUX_PLUGIN_MANAGER_PATH # rm -rf "$TMUX_PLUGIN_MANAGER_PATH" # tmux display 'Done uninstalling tpm and plugins...' # fi # else # if [ "$(command tmux display -p '#{pid} #{version} #{socket_path}')" = "$($TMUX_PROGRAM display -p '#{pid} #{version} #{socket_path}')" ]; then # tpm_plugins=$(cat << EOF | tr ' ' '\n' | awk '/^\s*$/ {next;}; !seen[$0]++ { gsub(/^[ \t]+/,"",$0); gsub(/[ \t]+$/,"",$0); print $0 }' +# "$tpm_plugins" # $(awk '/^[ \t]*set(-option)?.*[ \t]@plugin[ \t]/ { gsub(/'\''/, ""); gsub(/'\"'/, ""); print $NF }' "$TMUX_CONF_LOCAL" 2>/dev/null) # EOF # ) +# tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "$TMUX_PLUGIN_MANAGER_PATH" # tmux set -g '@tpm_plugins' "$tpm_plugins" # if git ls-remote -hq https://github.com/gpakosz/.tmux.git master > /dev/null; then # if [ ! -d "$TMUX_PLUGIN_MANAGER_PATH/tpm" ]; then @@ -1539,9 +1543,9 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # fi # # if [ "$_tmux_version" -gt 260 ]; then -# tmux set -gu '@tpm-install' \; set -gu '@tpm-update' \; set -gu '@tpm-clean' \; set -gu '@plugin' +# tmux set -gu '@tpm-install' \; set -gu '@tpm-update' \; set -gu '@tpm-clean' \; set -gu '@plugin' \; set -gu '@tpm_plugins' # else -# tmux set -g '@tpm-install' '' \; set -g '@tpm-update' '' \; set -g '@tpm-clean' '' \; set -g '@plugin' '' +# tmux set -g '@tpm-install' '' \; set -g '@tpm-update' '' \; set -g '@tpm-clean' '' \; set -g '@plugin' '' \; set-gu '@tpm_plugins' '' # fi # fi # } @@ -1551,18 +1555,14 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # tmux_conf_update_plugins_on_reload=${tmux_conf_update_plugins_on_reload:-true} # tmux_conf_uninstall_plugins_on_reload=${tmux_conf_uninstall_plugins_on_reload:-true} # -# tpm_plugins=$(tmux show -gvq '@tpm_plugins' 2>/dev/null) -# if [ -n "$(tmux show -gv '@plugin' 2>/dev/null)" ] || [ -n "$tpm_plugins" ]; then -# if [ -z "$TMUX_PLUGIN_MANAGER_PATH" ]; then -# if [ "$(dirname "$TMUX_CONF")" = "$HOME" ]; then -# TMUX_PLUGIN_MANAGER_PATH="$HOME/.tmux/plugins" -# else -# TMUX_PLUGIN_MANAGER_PATH="$(dirname "$TMUX_CONF")/plugins" -# fi -# tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "$TMUX_PLUGIN_MANAGER_PATH" +# if [ -z "$TMUX_PLUGIN_MANAGER_PATH" ]; then +# if [ "$(dirname "$TMUX_CONF")" = "$HOME" ]; then +# TMUX_PLUGIN_MANAGER_PATH="$HOME/.tmux/plugins" +# else +# TMUX_PLUGIN_MANAGER_PATH="$(dirname "$TMUX_CONF")/plugins" # fi -# tmux run -b "cut -c3- '$TMUX_CONF' | sh -s __apply_plugins '$window_active' '$tmux_conf_update_plugins_on_launch' '$tmux_conf_update_plugins_on_reload' '$tmux_conf_uninstall_plugins_on_reload'" # fi +# tmux run -b "cut -c3- '$TMUX_CONF' | sh -s __apply_plugins '$TMUX_PLUGIN_MANAGER_PATH' '$window_active' '$tmux_conf_update_plugins_on_launch' '$tmux_conf_update_plugins_on_reload' '$tmux_conf_uninstall_plugins_on_reload'" # } # # _apply_important() { diff --git a/.tmux.conf.local b/.tmux.conf.local index 01fa27a..88daa26 100644 --- a/.tmux.conf.local +++ b/.tmux.conf.local @@ -429,6 +429,8 @@ tmux_conf_uninstall_plugins_on_reload=true # then, use #{foo} in e.g. the 'tmux_conf_theme_status_left' or the # 'tmux_conf_theme_status_right' variables. +# ------------------------------------------------------------------------------ + # # /!\ do not remove the following line # EOF # @@ -445,3 +447,4 @@ tmux_conf_uninstall_plugins_on_reload=true # # "$@" # # /!\ do not remove the previous line +# # do not write below this line