1
0
Fork 0
mirror of synced 2024-12-14 03:15:47 -05:00

fix: use an alternate method to get TMUX_CMD_PATH

This commit is contained in:
michaellee8 2020-11-16 05:47:56 +00:00
parent d565659d46
commit f8044dbe23
5 changed files with 26 additions and 9 deletions

View file

@ -11,7 +11,7 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SCRIPTS_DIR="$CURRENT_DIR/../scripts" SCRIPTS_DIR="$CURRENT_DIR/../scripts"
HELPERS_DIR="$SCRIPTS_DIR/helpers" 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 "$SCRIPTS_DIR/tmux_cmd_path.sh"
source "$HELPERS_DIR/plugin_functions.sh" source "$HELPERS_DIR/plugin_functions.sh"
source "$HELPERS_DIR/tmux_echo_functions.sh" source "$HELPERS_DIR/tmux_echo_functions.sh"

View file

@ -3,7 +3,8 @@
VERSION="$1" VERSION="$1"
UNSUPPORTED_MSG="$2" UNSUPPORTED_MSG="$2"
export TMUX_CMD_PATH=$(realpath "/proc/$(tmux display -p '#{pid}')/exe" 2> /dev/null || echo "tmux" | sed -z '$ s/\n$//') source "$SCRIPTS_DIR/tmux_cmd_path.sh"
get_tmux_option() { get_tmux_option() {
local option=$1 local option=$1

View file

@ -1,10 +1,12 @@
source "$SCRIPTS_DIR/tmux_cmd_path.sh"
_has_emacs_mode_keys() { _has_emacs_mode_keys() {
$(tmux show -gw mode-keys | grep -q emacs) $($TMUX_CMD_PATH show -gw mode-keys | grep -q emacs)
} }
tmux_echo() { tmux_echo() {
local message="$1" local message="$1"
tmux run-shell "echo '$message'" $TMUX_CMD_PATH run-shell "echo '$message'"
} }
echo_ok() { echo_ok() {

18
scripts/tmux_cmd_path.sh Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
# Written by michaellee8 <ckmichael8@gmail.com> in Nov 2020 for
# https://github.com/tmux-plugins/tpm/issues/189 to prevent problems caused by
# tmux version mismatch between client and server. This script is
# licensed in public domain.
# Try to get the process ID of the running tmux server,
# would be empty if not found
TMUX_SERVER_PID=$(ps -eo pid=,comm= | grep 'tmux: server' | awk '{ print $1; }')
if [[ -n "$TMUX_SERVER_PID" ]]; then
TMUX_CMD_PATH=$(realpath "/proc/$TMUX_SERVER_PID/exe" 2> /dev/null || echo "tmux" | sed -z '$ s/\n$//')
else
TMUX_CMD_PATH='tmux'
fi
export TMUX_CMD_PATH

6
tpm
View file

@ -4,11 +4,7 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BINDINGS_DIR="$CURRENT_DIR/bindings" BINDINGS_DIR="$CURRENT_DIR/bindings"
SCRIPTS_DIR="$CURRENT_DIR/scripts" SCRIPTS_DIR="$CURRENT_DIR/scripts"
# Try to find the executable path of the currently running source "$SCRIPTS_DIR/tmux_cmd_path.sh"
# 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" source "$SCRIPTS_DIR/variables.sh"