mirror of
https://github.com/tmux-plugins/tmux-sensible.git
synced 2025-01-05 06:58:49 +00:00
fix: ensure that SCRIPT_DIR exists
This commit is contained in:
parent
f2c1b8aee6
commit
326fd5afe9
18
scripts/tmux_cmd_path.sh
Executable file
18
scripts/tmux_cmd_path.sh
Executable 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
|
@ -1,12 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
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/tmux_cmd_path.sh"
|
||||
|
||||
# used to match output from `tmux list-keys`
|
||||
KEY_BINDING_REGEX="bind-key[[:space:]]\+\(-r[[:space:]]\+\)\?\(-T prefix[[:space:]]\+\)\?"
|
||||
|
Loading…
Reference in New Issue
Block a user