From d565659d4608b4953c2c08d9cf092201d382db36 Mon Sep 17 00:00:00 2001 From: michaellee8 Date: Sun, 15 Nov 2020 15:49:39 +0000 Subject: [PATCH] fix: add TMUX_CMD_PATH to handle the case of multiple tmux installation --- bindings/update_plugins | 4 +++- scripts/check_tmux_version.sh | 8 +++++--- tpm | 10 ++++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bindings/update_plugins b/bindings/update_plugins index 28cc281..ce3df46 100755 --- a/bindings/update_plugins +++ b/bindings/update_plugins @@ -11,6 +11,8 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SCRIPTS_DIR="$CURRENT_DIR/../scripts" HELPERS_DIR="$SCRIPTS_DIR/helpers" +export TMUX_CMD_PATH=$(realpath "/proc/$(tmux display -p '#{pid}')/exe" 2> /dev/null || echo "tmux" | sed -z '$ s/\n$//') + source "$HELPERS_DIR/plugin_functions.sh" source "$HELPERS_DIR/tmux_echo_functions.sh" source "$HELPERS_DIR/tmux_utils.sh" @@ -36,7 +38,7 @@ display_plugin_update_list() { } update_plugin_prompt() { - tmux command-prompt -p 'plugin update:' " \ + $TMUX_CMD_PATH command-prompt -p 'plugin update:' " \ send-keys C-c; \ run-shell '$SCRIPTS_DIR/update_plugin_prompt_handler.sh %1'" } diff --git a/scripts/check_tmux_version.sh b/scripts/check_tmux_version.sh index b0aedec..77901b4 100755 --- a/scripts/check_tmux_version.sh +++ b/scripts/check_tmux_version.sh @@ -3,6 +3,8 @@ VERSION="$1" UNSUPPORTED_MSG="$2" +export TMUX_CMD_PATH=$(realpath "/proc/$(tmux display -p '#{pid}')/exe" 2> /dev/null || echo "tmux" | sed -z '$ s/\n$//') + get_tmux_option() { local option=$1 local default_value=$2 @@ -30,13 +32,13 @@ display_message() { local saved_display_time=$(get_tmux_option "display-time" "750") # sets message display time to 5 seconds - tmux set-option -gq display-time "$display_duration" + $TMUX_CMD_PATH set-option -gq display-time "$display_duration" # displays message - tmux display-message "$message" + $TMUX_CMD_PATH display-message "$message" # restores original 'display-time' value - tmux set-option -gq display-time "$saved_display_time" + $TMUX_CMD_PATH set-option -gq display-time "$saved_display_time" } # this is used to get "clean" integer version number. Examples: diff --git a/tpm b/tpm index 7ad4b99..a96b4b0 100755 --- a/tpm +++ b/tpm @@ -4,6 +4,12 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" BINDINGS_DIR="$CURRENT_DIR/bindings" SCRIPTS_DIR="$CURRENT_DIR/scripts" +# Try to find the executable path of the currently running +# tmux server, fallback to just "tmux" if not found or no +# procfs aviliable (non-linux). +export TMUX_CMD_PATH=$(realpath "/proc/$(tmux display -p '#{pid}')/exe" 2> /dev/null || echo "tmux" | sed -z '$ s/\n$//') +echo "tmux executable used: $TMUX_CMD_PATH" + source "$SCRIPTS_DIR/variables.sh" get_tmux_option() { @@ -18,7 +24,7 @@ get_tmux_option() { } tpm_path_set() { - tmux show-environment -g "$DEFAULT_TPM_ENV_VAR_NAME" >/dev/null 2>&1 + $TMUX_CMD_PATH show-environment -g "$DEFAULT_TPM_ENV_VAR_NAME" >/dev/null 2>&1 } # Check if configuration file exists at an XDG-compatible location, if so use @@ -31,7 +37,7 @@ set_default_tpm_path() { tpm_path="$xdg_tmux_path/plugins/" fi - tmux set-environment -g "$DEFAULT_TPM_ENV_VAR_NAME" "$tpm_path" + $TMUX_CMD_PATH set-environment -g "$DEFAULT_TPM_ENV_VAR_NAME" "$tpm_path" } # Ensures TMUX_PLUGIN_MANAGER_PATH global env variable is set.