mirror of
https://github.com/tmux-plugins/tpm.git
synced 2024-12-04 18:58:49 +00:00
TPM path refactoring
This commit is contained in:
parent
57c0623fb8
commit
cd97b4bceb
@ -10,6 +10,7 @@
|
|||||||
- add `bin/update_plugins` cli executable script
|
- add `bin/update_plugins` cli executable script
|
||||||
- refactor test `expect` scripts, make them simpler and ensure they properly
|
- refactor test `expect` scripts, make them simpler and ensure they properly
|
||||||
assert expectations
|
assert expectations
|
||||||
|
- refactor code that sets 'TMUX_PLUGIN_MANAGER_PATH' global env var
|
||||||
|
|
||||||
### v2.0.0, 2015-07-07
|
### v2.0.0, 2015-07-07
|
||||||
- enable overriding default key bindings
|
- enable overriding default key bindings
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
default_tpm_path="$HOME/.tmux/plugins/"
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
source "$CURRENT_DIR/variables.sh"
|
||||||
|
|
||||||
tpm_path_set() {
|
tpm_path_set() {
|
||||||
tmux show-environment -g TMUX_PLUGIN_MANAGER_PATH
|
tmux show-environment -g "$DEFAULT_TPM_ENV_VAR_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
set_default_tpm_path() {
|
set_default_tpm_path() {
|
||||||
tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "$default_tpm_path"
|
tmux set-environment -g "$DEFAULT_TPM_ENV_VAR_NAME" "$DEFAULT_TPM_PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
@ -8,3 +8,6 @@ clean_key_option="@tpm-clean"
|
|||||||
default_clean_key="M-u"
|
default_clean_key="M-u"
|
||||||
|
|
||||||
SUPPORTED_TMUX_VERSION="1.9"
|
SUPPORTED_TMUX_VERSION="1.9"
|
||||||
|
|
||||||
|
DEFAULT_TPM_ENV_VAR_NAME="TMUX_PLUGIN_MANAGER_PATH"
|
||||||
|
DEFAULT_TPM_PATH="$HOME/.tmux/plugins/"
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
TPM_DIR="$PWD"
|
TPM_DIR="$PWD"
|
||||||
|
PLUGINS_DIR="$HOME/.tmux/plugins"
|
||||||
|
|
||||||
|
CUSTOM_PLUGINS_DIR="$HOME/foo/plugins"
|
||||||
|
|
||||||
source "$CURRENT_DIR/helpers/helpers.sh"
|
source "$CURRENT_DIR/helpers/helpers.sh"
|
||||||
source "$CURRENT_DIR/helpers/tpm.sh"
|
source "$CURRENT_DIR/helpers/tpm.sh"
|
||||||
@ -12,16 +15,22 @@ check_binding_defined() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
create_test_plugin_helper() {
|
create_test_plugin_helper() {
|
||||||
local plugin_path="$HOME/.tmux/plugins/tmux_test_plugin/"
|
local plugin_path="$PLUGINS_DIR/tmux_test_plugin/"
|
||||||
rm -rf $plugin_path
|
rm -rf "$plugin_path"
|
||||||
mkdir -p $plugin_path
|
mkdir -p "$plugin_path"
|
||||||
|
|
||||||
while read -r line; do
|
while read line; do
|
||||||
echo $line >> "$plugin_path/test_plugin.tmux"
|
echo "$line" >> "$plugin_path/test_plugin.tmux"
|
||||||
done
|
done
|
||||||
chmod +x "$plugin_path/test_plugin.tmux"
|
chmod +x "$plugin_path/test_plugin.tmux"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_tpm_path() {
|
||||||
|
local correct_tpm_path="$1"
|
||||||
|
local tpm_path="$(tmux start-server\; show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)"
|
||||||
|
[ "$correct_tpm_path" == "$tpm_path" ]
|
||||||
|
}
|
||||||
|
|
||||||
test_plugin_sourcing() {
|
test_plugin_sourcing() {
|
||||||
set_tmux_conf_helper <<- HERE
|
set_tmux_conf_helper <<- HERE
|
||||||
set -g @plugin "doesnt_matter/tmux_test_plugin"
|
set -g @plugin "doesnt_matter/tmux_test_plugin"
|
||||||
@ -40,4 +49,27 @@ test_plugin_sourcing() {
|
|||||||
teardown_helper
|
teardown_helper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_default_tpm_path() {
|
||||||
|
set_tmux_conf_helper <<- HERE
|
||||||
|
run-shell "$TPM_DIR/tpm"
|
||||||
|
HERE
|
||||||
|
|
||||||
|
check_tpm_path "$PLUGINS_DIR" ||
|
||||||
|
fail_helper "Default TPM path not correct"
|
||||||
|
|
||||||
|
teardown_helper
|
||||||
|
}
|
||||||
|
|
||||||
|
test_custom_tpm_path() {
|
||||||
|
set_tmux_conf_helper <<- HERE
|
||||||
|
set-environment -g TMUX_PLUGIN_MANAGER_PATH '$CUSTOM_PLUGINS_DIR'
|
||||||
|
run-shell "$TPM_DIR/tpm"
|
||||||
|
HERE
|
||||||
|
|
||||||
|
check_tpm_path "$CUSTOM_PLUGINS_DIR" ||
|
||||||
|
fail_helper "Custom TPM path not correct"
|
||||||
|
|
||||||
|
teardown_helper
|
||||||
|
}
|
||||||
|
|
||||||
run_tests
|
run_tests
|
||||||
|
Loading…
Reference in New Issue
Block a user