Skip to content

Commit b36202a

Browse files
authored
Merge pull request tmux-plugins#177 from Ambroisie/detect-xdg-config
Use XDG-compatible plugin path when available
2 parents 59f7885 + 425cabe commit b36202a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

docs/changing_plugins_install_dir.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changing plugins install dir
22

3-
By default, TPM installs plugins to `~/.tmux/plugins/`.
3+
By default, TPM installs plugins in a subfolder named `plugins/` inside
4+
`$XDG_CONFIG_HOME/tmux/` if a `tmux.conf` file was found at that location, or
5+
inside `~/.tmux/` otherwise.
46

57
You can change the install path by putting this in `.tmux.conf`:
68

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)