Merge branch 'master' into add-branch-to-plugin

This commit is contained in:
Rafał Rothenberger 2021-06-29 09:03:20 +02:00 committed by GitHub
commit e019ff1fe9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 23 deletions

View File

@ -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` + <kbd>alt</kbd> + <kbd>u</kbd>
- 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)

View File

@ -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`:

View File

@ -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

View File

@ -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
}

11
tpm
View File

@ -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.