Refactor how TPM path is set

This commit is contained in:
Bruno Sutic 2015-08-03 01:11:39 +02:00
parent cd97b4bceb
commit 0f0d9adb06
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
3 changed files with 12 additions and 24 deletions

View File

@ -1,20 +0,0 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/variables.sh"
tpm_path_set() {
tmux show-environment -g "$DEFAULT_TPM_ENV_VAR_NAME"
}
set_default_tpm_path() {
tmux set-environment -g "$DEFAULT_TPM_ENV_VAR_NAME" "$DEFAULT_TPM_PATH"
}
main() {
if ! tpm_path_set; then
set_default_tpm_path
fi
}
main

View File

@ -54,7 +54,7 @@ test_default_tpm_path() {
run-shell "$TPM_DIR/tpm" run-shell "$TPM_DIR/tpm"
HERE HERE
check_tpm_path "$PLUGINS_DIR" || check_tpm_path "${PLUGINS_DIR}/" ||
fail_helper "Default TPM path not correct" fail_helper "Default TPM path not correct"
teardown_helper teardown_helper

14
tpm
View File

@ -7,14 +7,22 @@ SCRIPTS_DIR="$CURRENT_DIR/scripts"
source "$SCRIPTS_DIR/variables.sh" source "$SCRIPTS_DIR/variables.sh"
source "$SCRIPTS_DIR/helpers.sh" source "$SCRIPTS_DIR/helpers.sh"
tpm_path_set() {
tmux show-environment -g "$DEFAULT_TPM_ENV_VAR_NAME" >/dev/null 2>&1
}
set_default_tpm_path() {
tmux set-environment -g "$DEFAULT_TPM_ENV_VAR_NAME" "$DEFAULT_TPM_PATH"
}
# Ensures TMUX_PLUGIN_MANAGER_PATH global env variable is set. # Ensures TMUX_PLUGIN_MANAGER_PATH global env variable is set.
# Default tpm path is "$HOME/.tmux/plugins/". That's where all the plugins are
# downloaded.
# #
# Put this in `.tmux.conf` to override the default: # Put this in `.tmux.conf` to override the default:
# `set-environment -g TMUX_PLUGIN_MANAGER_PATH "/some/other/path/"` # `set-environment -g TMUX_PLUGIN_MANAGER_PATH "/some/other/path/"`
set_tpm_path() { set_tpm_path() {
"$SCRIPTS_DIR/set_tpm_path.sh" >/dev/null 2>&1 if ! tpm_path_set; then
set_default_tpm_path
fi
} }
# 1. Fetches plugin names from `@plugin` variables # 1. Fetches plugin names from `@plugin` variables