Use XDG-compatible plugin path when available

If the `tmux.conf` file is found at a XDG_CONFIG_HOME, use this
directory to store the plugins instead of `$HONE/.tmux/`.

This is only effective if the user has not overridden the value of
`TMUX_PLUGIN_MANAGER_PATH` in their configuration file.
pull/177/head
Bruno BELANYI 2020-08-28 16:55:51 +02:00
parent 59f78857f6
commit 9d2a389f90
1 changed files with 10 additions and 1 deletions

11
tpm
View File

@ -21,8 +21,17 @@ tpm_path_set() {
tmux 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
# that directory for TMUX_PLUGIN_MANAGER_PATH. Otherwise use $DEFAULT_TPM_PATH.
set_default_tpm_path() {
tmux set-environment -g "$DEFAULT_TPM_ENV_VAR_NAME" "$DEFAULT_TPM_PATH"
local xdg_tmux_path="${XDG_CONFIG_HOME:-$HOME/.config}/tmux"
local tpm_path="$DEFAULT_TPM_PATH"
if [ -f "$xdg_tmux_path/tmux.conf" ]; then
tpm_path="$xdg_tmux_path/plugins/"
fi
tmux set-environment -g "$DEFAULT_TPM_ENV_VAR_NAME" "$tpm_path"
}
# Ensures TMUX_PLUGIN_MANAGER_PATH global env variable is set.