Skip to content

Commit 9d2a389

Browse files
committed
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.
1 parent 59f7885 commit 9d2a389

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tpm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@ tpm_path_set() {
2121
tmux show-environment -g "$DEFAULT_TPM_ENV_VAR_NAME" >/dev/null 2>&1
2222
}
2323

24+
# Check if configuration file exists at an XDG-compatible location, if so use
25+
# that directory for TMUX_PLUGIN_MANAGER_PATH. Otherwise use $DEFAULT_TPM_PATH.
2426
set_default_tpm_path() {
25-
tmux set-environment -g "$DEFAULT_TPM_ENV_VAR_NAME" "$DEFAULT_TPM_PATH"
27+
local xdg_tmux_path="${XDG_CONFIG_HOME:-$HOME/.config}/tmux"
28+
local tpm_path="$DEFAULT_TPM_PATH"
29+
30+
if [ -f "$xdg_tmux_path/tmux.conf" ]; then
31+
tpm_path="$xdg_tmux_path/plugins/"
32+
fi
33+
34+
tmux set-environment -g "$DEFAULT_TPM_ENV_VAR_NAME" "$tpm_path"
2635
}
2736

2837
# Ensures TMUX_PLUGIN_MANAGER_PATH global env variable is set.

0 commit comments

Comments
 (0)