Skip to content

Commit e019ff1

Browse files
Merge branch 'master' into add-branch-to-plugin
2 parents fe5e131 + 2afeff1 commit e019ff1

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

README.md

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Installs and loads `tmux` plugins.
66

77
Tested and working on Linux, OSX, and Cygwin.
88

9+
See list of plugins [here](https://github.com/tmux-plugins/list).
10+
911
### Installation
1012

1113
Requirements: `tmux` version 1.9 (or higher), `git`, `bash`.
@@ -27,11 +29,11 @@ set -g @plugin 'tmux-plugins/tmux-sensible'
2729
# Other examples:
2830
# set -g @plugin 'github_username/plugin_name'
2931
# set -g @plugin 'github_username/plugin_name#branch'
30-
# set -g @plugin '[email protected]/user/plugin'
31-
# set -g @plugin '[email protected]/user/plugin'
32+
# set -g @plugin '[email protected]:user/plugin'
33+
# set -g @plugin '[email protected]:user/plugin'
3234

3335
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
34-
run -b '~/.tmux/plugins/tpm/tpm'
36+
run '~/.tmux/plugins/tpm/tpm'
3537
```
3638

3739
Reload TMUX environment so TPM is sourced:
@@ -70,10 +72,6 @@ find plugin directory there and remove it.
7072
`prefix` + <kbd>alt</kbd> + <kbd>u</kbd>
7173
- remove/uninstall plugins not on the plugin list
7274

73-
### More plugins
74-
75-
For more plugins, check [here](https://github.com/tmux-plugins).
76-
7775
### Docs
7876

7977
- [Help, tpm not working](docs/tpm_not_working.md) - problem solutions
@@ -98,17 +96,6 @@ Run tests with:
9896
$ ./run_tests
9997
```
10098

101-
### Other goodies
102-
103-
- [tmux-copycat](https://github.com/tmux-plugins/tmux-copycat) - a plugin for
104-
regex searches in tmux and fast match selection
105-
- [tmux-yank](https://github.com/tmux-plugins/tmux-yank) - enables copying
106-
highlighted text to system clipboard
107-
- [tmux-open](https://github.com/tmux-plugins/tmux-open) - a plugin for quickly
108-
opening highlighted file or a url
109-
- [tmux-continuum](https://github.com/tmux-plugins/tmux-continuum) - automatic
110-
restoring and continuous saving of tmux env
111-
11299
### License
113100

114101
[MIT](LICENSE.md)

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

scripts/helpers/plugin_functions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ _CACHED_TPM_PATH="$(_tpm_path)"
2020
#
2121
_get_user_tmux_conf() {
2222
# Define the different possible locations.
23-
xdg_location="$XDG_CONFIG_HOME/tmux/tmux.conf"
23+
xdg_location="${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf"
2424
default_location="$HOME/.tmux.conf"
2525

2626
# Search for the correct configuration file by priority.
@@ -46,7 +46,7 @@ _tmux_conf_contents() {
4646
# return files sourced from tmux config files
4747
_sourced_files() {
4848
_tmux_conf_contents |
49-
awk '/^[ \t]*source(-file)? +/ { gsub(/'\''/,""); gsub(/'\"'/,""); print $2 }'
49+
sed -E -n -e "s/^[[:space:]]*source(-file)?[[:space:]]+(-q+[[:space:]]+)?['\"]?([^'\"]+)['\"]?/\3/p"
5050
}
5151

5252
# Want to be able to abort in certain cases

scripts/helpers/tmux_utils.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
HELPERS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2+
source "$HELPERS_DIR/plugin_functions.sh"
3+
14
reload_tmux_environment() {
2-
tmux source-file ~/.tmux.conf >/dev/null 2>&1
5+
tmux source-file $(_get_user_tmux_conf) >/dev/null 2>&1
36
}

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)