diff --git a/README.md b/README.md
index 29c179f..fe90855 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`.
@@ -27,11 +29,11 @@ set -g @plugin 'tmux-plugins/tmux-sensible'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'github_username/plugin_name#branch'
-# 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'
+run '~/.tmux/plugins/tpm/tpm'
```
Reload TMUX environment so TPM is sourced:
@@ -70,10 +72,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
@@ -98,17 +96,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)
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`:
diff --git a/scripts/helpers/plugin_functions.sh b/scripts/helpers/plugin_functions.sh
index cbd1b55..f33d215 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.
@@ -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
diff --git a/scripts/helpers/tmux_utils.sh b/scripts/helpers/tmux_utils.sh
index e39946a..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 ~/.tmux.conf >/dev/null 2>&1
+ tmux source-file $(_get_user_tmux_conf) >/dev/null 2>&1
}
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.