From 9d2a389f9028dc71909814c32862a59440cc3968 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 28 Aug 2020 16:55:51 +0200 Subject: [PATCH 1/2] 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. --- tpm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tpm b/tpm index 570d58b..7ad4b99 100755 --- a/tpm +++ b/tpm @@ -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. From 425cabe9413697c415034febaf044037689a84b9 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 28 Aug 2020 17:36:20 +0200 Subject: [PATCH 2/2] Explain XDG-compatible plugin path in docs Reword the documentation file explaining how to change the path were `tpm` installs its plugins to mention the new behaviour regarding XDG_CONFIG_HOME. --- docs/changing_plugins_install_dir.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/changing_plugins_install_dir.md b/docs/changing_plugins_install_dir.md index 93af675..27de96d 100644 --- a/docs/changing_plugins_install_dir.md +++ b/docs/changing_plugins_install_dir.md @@ -1,6 +1,8 @@ # Changing plugins install dir -By default, TPM installs plugins to `~/.tmux/plugins/`. +By default, TPM installs plugins in a subfolder named `plugins/` inside +`$XDG_CONFIG_HOME/tmux/` if a `tmux.conf` file was found at that location, or +inside `~/.tmux/` otherwise. You can change the install path by putting this in `.tmux.conf`: