Merge 3206dec40b
into 38576cf76e
This commit is contained in:
commit
eb20e47f3e
|
@ -11,6 +11,8 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||
SCRIPTS_DIR="$CURRENT_DIR/../scripts"
|
||||
HELPERS_DIR="$SCRIPTS_DIR/helpers"
|
||||
|
||||
source "$SCRIPTS_DIR/tmux_cmd_path.sh"
|
||||
|
||||
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'"
|
||||
}
|
||||
|
|
|
@ -3,10 +3,17 @@
|
|||
VERSION="$1"
|
||||
UNSUPPORTED_MSG="$2"
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SCRIPTS_DIR="$CURRENT_DIR/../scripts"
|
||||
HELPERS_DIR="$SCRIPTS_DIR/helpers"
|
||||
|
||||
source "$SCRIPTS_DIR/tmux_cmd_path.sh"
|
||||
|
||||
|
||||
get_tmux_option() {
|
||||
local option=$1
|
||||
local default_value=$2
|
||||
local option_value=$(tmux show-option -gqv "$option")
|
||||
local option_value=$($TMUX_CMD_PATH show-option -gqv "$option")
|
||||
if [ -z "$option_value" ]; then
|
||||
echo "$default_value"
|
||||
else
|
||||
|
@ -30,13 +37,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:
|
||||
|
@ -49,7 +56,7 @@ get_digits_from_string() {
|
|||
}
|
||||
|
||||
tmux_version_int() {
|
||||
local tmux_version_string=$(tmux -V)
|
||||
local tmux_version_string=$($TMUX_CMD_PATH -V)
|
||||
echo "$(get_digits_from_string "$tmux_version_string")"
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
# using @tpm_plugins is now deprecated in favor of using @plugin syntax
|
||||
tpm_plugins_variable_name="@tpm_plugins"
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SCRIPTS_DIR="$CURRENT_DIR/../../scripts"
|
||||
HELPERS_DIR="$SCRIPTS_DIR/helpers"
|
||||
source "$SCRIPTS_DIR/tmux_cmd_path.sh"
|
||||
|
||||
# manually expanding tilde char or `$HOME` variable.
|
||||
_manual_expansion() {
|
||||
local path="$1"
|
||||
|
@ -9,7 +14,7 @@ _manual_expansion() {
|
|||
}
|
||||
|
||||
_tpm_path() {
|
||||
local string_path="$(tmux start-server\; show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)/"
|
||||
local string_path="$($TMUX_CMD_PATH start-server\; show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)/"
|
||||
_manual_expansion "$string_path"
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SCRIPTS_DIR="$CURRENT_DIR/../../scripts"
|
||||
HELPERS_DIR="$SCRIPTS_DIR/helpers"
|
||||
source "$SCRIPTS_DIR/tmux_cmd_path.sh"
|
||||
|
||||
_has_emacs_mode_keys() {
|
||||
$(tmux show -gw mode-keys | grep -q emacs)
|
||||
$($TMUX_CMD_PATH show -gw mode-keys | grep -q emacs)
|
||||
}
|
||||
|
||||
tmux_echo() {
|
||||
local message="$1"
|
||||
tmux run-shell "echo '$message'"
|
||||
$TMUX_CMD_PATH run-shell "echo '$message'"
|
||||
}
|
||||
|
||||
echo_ok() {
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SCRIPTS_DIR="$CURRENT_DIR/../../scripts"
|
||||
HELPERS_DIR="$SCRIPTS_DIR/helpers"
|
||||
source "$SCRIPTS_DIR/tmux_cmd_path.sh"
|
||||
|
||||
reload_tmux_environment() {
|
||||
tmux source-file ~/.tmux.conf >/dev/null 2>&1
|
||||
$TMUX_CMD_PATH source-file ~/.tmux.conf >/dev/null 2>&1
|
||||
}
|
||||
|
|
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
|
14
tpm
14
tpm
|
@ -4,12 +4,14 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||
BINDINGS_DIR="$CURRENT_DIR/bindings"
|
||||
SCRIPTS_DIR="$CURRENT_DIR/scripts"
|
||||
|
||||
source "$SCRIPTS_DIR/tmux_cmd_path.sh"
|
||||
|
||||
source "$SCRIPTS_DIR/variables.sh"
|
||||
|
||||
get_tmux_option() {
|
||||
local option="$1"
|
||||
local default_value="$2"
|
||||
local option_value="$(tmux show-option -gqv "$option")"
|
||||
local option_value="$($TMUX_CMD_PATH show-option -gqv "$option")"
|
||||
if [ -z "$option_value" ]; then
|
||||
echo "$default_value"
|
||||
else
|
||||
|
@ -18,7 +20,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 +33,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.
|
||||
|
@ -58,13 +60,13 @@ source_plugins() {
|
|||
# prefix + alt + u - remove unused TPM plugins and reloads TMUX environment
|
||||
set_tpm_key_bindings() {
|
||||
local install_key="$(get_tmux_option "$install_key_option" "$default_install_key")"
|
||||
tmux bind-key "$install_key" run-shell "$BINDINGS_DIR/install_plugins"
|
||||
$TMUX_CMD_PATH bind-key "$install_key" run-shell "$BINDINGS_DIR/install_plugins"
|
||||
|
||||
local update_key="$(get_tmux_option "$update_key_option" "$default_update_key")"
|
||||
tmux bind-key "$update_key" run-shell "$BINDINGS_DIR/update_plugins"
|
||||
$TMUX_CMD_PATH bind-key "$update_key" run-shell "$BINDINGS_DIR/update_plugins"
|
||||
|
||||
local clean_key="$(get_tmux_option "$clean_key_option" "$default_clean_key")"
|
||||
tmux bind-key "$clean_key" run-shell "$BINDINGS_DIR/clean_plugins"
|
||||
$TMUX_CMD_PATH bind-key "$clean_key" run-shell "$BINDINGS_DIR/clean_plugins"
|
||||
}
|
||||
|
||||
supported_tmux_version_ok() {
|
||||
|
|
Loading…
Reference in a new issue