From 7c3a16e2431b3b28e78585729db70bf90e4797af Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Tue, 16 Jul 2019 20:58:31 +0200 Subject: [PATCH 01/10] Default value for XDG_CONFIG_HOME --- scripts/helpers/plugin_functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/plugin_functions.sh b/scripts/helpers/plugin_functions.sh index cbd1b55..14721c2 100644 --- a/scripts/helpers/plugin_functions.sh +++ b/scripts/helpers/plugin_functions.sh @@ -20,7 +20,7 @@ _CACHED_TPM_PATH="$(_tpm_path)" # _get_user_tmux_conf() { # Define the different possible locations. - xdg_location="$XDG_CONFIG_HOME/tmux/tmux.conf" + xdg_location="${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf" default_location="$HOME/.tmux.conf" # Search for the correct configuration file by priority. From 788f5d68af525a3af22aaa5507afd0e7a3de0d50 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Fri, 28 Feb 2020 14:08:57 +0100 Subject: [PATCH 02/10] Add support for 'source-file -q', fixes #135 Starting from tmux 2.3, 'source-file' understands '-q' to suppress errors for nonexistent files. --- scripts/helpers/plugin_functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/plugin_functions.sh b/scripts/helpers/plugin_functions.sh index 14721c2..f33d215 100644 --- a/scripts/helpers/plugin_functions.sh +++ b/scripts/helpers/plugin_functions.sh @@ -46,7 +46,7 @@ _tmux_conf_contents() { # return files sourced from tmux config files _sourced_files() { _tmux_conf_contents | - awk '/^[ \t]*source(-file)? +/ { gsub(/'\''/,""); gsub(/'\"'/,""); print $2 }' + sed -E -n -e "s/^[[:space:]]*source(-file)?[[:space:]]+(-q+[[:space:]]+)?['\"]?([^'\"]+)['\"]?/\3/p" } # Want to be able to abort in certain cases From 4a3fdeca47f34949ebd8f1c8ad464eb7023f8d80 Mon Sep 17 00:00:00 2001 From: Joseph Dalrymple Date: Wed, 3 Jun 2020 14:31:31 -0500 Subject: [PATCH 03/10] Fixed Git Plugin Example I thought it was a bit peculiar that the README.md suggested using `git@bitbucket.com/user/plugin`, but went ahead with that syntax. After seemingly endlessly scratching my head, while trying to figure out what the issue, I reverted to the traditional git URL syntax (SSH syntax) and it worked. ``` set -g @plugin 'git@bitbucket.com:user/plugin_name` ``` Verified by running `./.tmux/plugins/tpm/bin/install_plugins` manually with a fresh version of TMUX + TPM with both styles. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9fb8232..824a557 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,8 @@ set -g @plugin 'tmux-plugins/tmux-sensible' # Other examples: # set -g @plugin 'github_username/plugin_name' -# set -g @plugin 'git@github.com/user/plugin' -# set -g @plugin 'git@bitbucket.com/user/plugin' +# set -g @plugin 'git@github.com:user/plugin' +# set -g @plugin 'git@bitbucket.com:user/plugin' # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) run -b '~/.tmux/plugins/tpm/tpm' From 59f78857f656afd462d7bc99b31cc8cc36c1872c Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Mon, 6 Jul 2020 09:34:03 +0200 Subject: [PATCH 04/10] Revert "Update README.md installation instructions." This reverts commit a403ca3b67f880fc3ef3f585bae2779932570cf5. There are problems when running TPM with a `-b` flag, see #151. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 824a557..1386e42 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ set -g @plugin 'tmux-plugins/tmux-sensible' # set -g @plugin 'git@bitbucket.com:user/plugin' # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) -run -b '~/.tmux/plugins/tpm/tpm' +run '~/.tmux/plugins/tpm/tpm' ``` Reload TMUX environment so TPM is sourced: From 9d2a389f9028dc71909814c32862a59440cc3968 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 28 Aug 2020 16:55:51 +0200 Subject: [PATCH 05/10] 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 06/10] 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`: From 38576cf76ea0d9959dae8bccc77306e70b318f8e Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Tue, 19 Jan 2021 13:55:49 +0100 Subject: [PATCH 07/10] Add tmux-plugins/list to the readme --- README.md | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1386e42..31bade0 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ Installs and loads `tmux` plugins. Tested and working on Linux, OSX, and Cygwin. +See list of plugins [here](https://github.com/tmux-plugins/list). + ### Installation Requirements: `tmux` version 1.9 (or higher), `git`, `bash`. @@ -69,10 +71,6 @@ find plugin directory there and remove it. `prefix` + alt + u - remove/uninstall plugins not on the plugin list -### More plugins - -For more plugins, check [here](https://github.com/tmux-plugins). - ### Docs - [Help, tpm not working](docs/tpm_not_working.md) - problem solutions @@ -97,17 +95,6 @@ Run tests with: $ ./run_tests ``` -### Other goodies - -- [tmux-copycat](https://github.com/tmux-plugins/tmux-copycat) - a plugin for - regex searches in tmux and fast match selection -- [tmux-yank](https://github.com/tmux-plugins/tmux-yank) - enables copying - highlighted text to system clipboard -- [tmux-open](https://github.com/tmux-plugins/tmux-open) - a plugin for quickly - opening highlighted file or a url -- [tmux-continuum](https://github.com/tmux-plugins/tmux-continuum) - automatic - restoring and continuous saving of tmux env - ### License [MIT](LICENSE.md) From f79c59314ce9baa70de736340060e4a135f8c5a8 Mon Sep 17 00:00:00 2001 From: Edgar Handal Date: Mon, 22 Feb 2021 19:59:32 -0600 Subject: [PATCH 08/10] Fix hardcoded tmux.conf path in environment reload --- scripts/helpers/tmux_utils.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/helpers/tmux_utils.sh b/scripts/helpers/tmux_utils.sh index e39946a..dc6df41 100644 --- a/scripts/helpers/tmux_utils.sh +++ b/scripts/helpers/tmux_utils.sh @@ -1,3 +1,6 @@ +CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "$CURRENT_DIR/plugin_functions.sh" + reload_tmux_environment() { - tmux source-file ~/.tmux.conf >/dev/null 2>&1 + tmux source-file $(_get_user_tmux_conf) >/dev/null 2>&1 } From 0a19b28b4e1c1ad87932d633516b9c963e9f58bd Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Mon, 15 Mar 2021 11:41:53 +0100 Subject: [PATCH 09/10] Remove `CURRENT_DIR` variable from a helper script Fixes #200 --- scripts/helpers/tmux_utils.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/helpers/tmux_utils.sh b/scripts/helpers/tmux_utils.sh index dc6df41..150e6b9 100644 --- a/scripts/helpers/tmux_utils.sh +++ b/scripts/helpers/tmux_utils.sh @@ -1,6 +1,3 @@ -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source "$CURRENT_DIR/plugin_functions.sh" - reload_tmux_environment() { tmux source-file $(_get_user_tmux_conf) >/dev/null 2>&1 } From 2afeff1529ec85d0c5ced5ece3714c2220b646a5 Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Mon, 15 Mar 2021 11:50:50 +0100 Subject: [PATCH 10/10] Add 'HELPERS_DIR' variable to tmux_utils.sh --- scripts/helpers/tmux_utils.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/helpers/tmux_utils.sh b/scripts/helpers/tmux_utils.sh index 150e6b9..238952d 100644 --- a/scripts/helpers/tmux_utils.sh +++ b/scripts/helpers/tmux_utils.sh @@ -1,3 +1,6 @@ +HELPERS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "$HELPERS_DIR/plugin_functions.sh" + reload_tmux_environment() { tmux source-file $(_get_user_tmux_conf) >/dev/null 2>&1 }