From 0f0d9adb06ab5c432b464f57b0b576914f51ef85 Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Mon, 3 Aug 2015 01:11:39 +0200 Subject: [PATCH] Refactor how TPM path is set --- scripts/set_tpm_path.sh | 20 -------------------- tests/test_plugin_sourcing.sh | 2 +- tpm | 14 +++++++++++--- 3 files changed, 12 insertions(+), 24 deletions(-) delete mode 100755 scripts/set_tpm_path.sh diff --git a/scripts/set_tpm_path.sh b/scripts/set_tpm_path.sh deleted file mode 100755 index d870329..0000000 --- a/scripts/set_tpm_path.sh +++ /dev/null @@ -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 diff --git a/tests/test_plugin_sourcing.sh b/tests/test_plugin_sourcing.sh index f609a31..4398d9f 100755 --- a/tests/test_plugin_sourcing.sh +++ b/tests/test_plugin_sourcing.sh @@ -54,7 +54,7 @@ test_default_tpm_path() { run-shell "$TPM_DIR/tpm" HERE - check_tpm_path "$PLUGINS_DIR" || + check_tpm_path "${PLUGINS_DIR}/" || fail_helper "Default TPM path not correct" teardown_helper diff --git a/tpm b/tpm index 5851241..ef30c07 100755 --- a/tpm +++ b/tpm @@ -7,14 +7,22 @@ SCRIPTS_DIR="$CURRENT_DIR/scripts" source "$SCRIPTS_DIR/variables.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. -# Default tpm path is "$HOME/.tmux/plugins/". That's where all the plugins are -# downloaded. # # Put this in `.tmux.conf` to override the default: # `set-environment -g TMUX_PLUGIN_MANAGER_PATH "/some/other/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