1
0
Fork 0
mirror of synced 2024-11-10 19:48:57 -05:00

Stop using global variable for tpm path

This commit is contained in:
Bruno Sutic 2015-08-03 15:29:53 +02:00
parent 79d90f90f7
commit 0e9b64ffc4
No known key found for this signature in database
GPG key ID: 66D96E4F2F7EF26C
7 changed files with 16 additions and 15 deletions

View file

@ -11,6 +11,7 @@
- refactor test `expect` scripts, make them simpler and ensure they properly
assert expectations
- refactor code that sets 'TMUX_PLUGIN_MANAGER_PATH' global env var
- stop using global variable for 'tpm path'
### v2.0.0, 2015-07-07
- enable overriding default key bindings

View file

@ -43,7 +43,6 @@ update_plugin_prompt() {
main() {
reload_tmux_environment
shared_set_tpm_path_constant
display_plugin_update_list
update_plugin_prompt
}

View file

@ -15,7 +15,7 @@ clean_plugins() {
local plugins plugin plugin_directory
plugins="$(shared_get_tpm_plugins_list)"
for plugin_directory in "$SHARED_TPM_PATH"/*; do
for plugin_directory in "$(tpm_path)"/*; do
[ -d "${plugin_directory}" ] || continue
plugin="$(shared_plugin_name "${plugin_directory}")"
case "${plugins}" in
@ -33,7 +33,6 @@ clean_plugins() {
}
main() {
shared_set_tpm_path_constant
ensure_tpm_path_exists
clean_plugins
exit_value_helper

View file

@ -13,7 +13,7 @@ fi
clone() {
local plugin="$1"
cd "$SHARED_TPM_PATH" &&
cd "$(tpm_path)" &&
GIT_TERMINAL_PROMPT=0 git clone --recursive "$plugin" >/dev/null 2>&1
}
@ -49,14 +49,14 @@ install_plugins() {
}
verify_tpm_path_permissions() {
local path="$(tpm_path)"
# check the write permission flag for all users to ensure
# that we have proper access
[ -w "$SHARED_TPM_PATH" ] ||
echo_err "$SHARED_TPM_PATH is not writable!"
[ -w "$path" ] ||
echo_err "$path is not writable!"
}
main() {
shared_set_tpm_path_constant
ensure_tpm_path_exists
verify_tpm_path_permissions
install_plugins

View file

@ -2,14 +2,18 @@
# using @tpm_plugins is now deprecated in favor of using @plugin syntax
tpm_plugins_variable_name="@tpm_plugins"
SHARED_TPM_PATH=""
# sets a "global variable" for the current file
shared_set_tpm_path_constant() {
_tpm_path() {
local string_path="$(tmux start-server\; show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)/"
# manually expanding tilde or `$HOME` variable.
string_path="${string_path/#\~/$HOME}"
SHARED_TPM_PATH="${string_path/#\$HOME/$HOME}"
echo "${string_path/#\$HOME/$HOME}"
}
_CACHED_TPM_PATH="$(_tpm_path)"
tpm_path() {
echo "$_CACHED_TPM_PATH"
}
_tmux_conf_contents() {
@ -40,7 +44,7 @@ shared_plugin_name() {
shared_plugin_path() {
local plugin="$1"
local plugin_name="$(shared_plugin_name "$plugin")"
echo "${SHARED_TPM_PATH}${plugin_name}/"
echo "$(tpm_path)${plugin_name}/"
}
plugin_already_installed() {
@ -52,7 +56,7 @@ plugin_already_installed() {
}
ensure_tpm_path_exists() {
mkdir -p "$SHARED_TPM_PATH"
mkdir -p "$(tpm_path)"
}
fail_helper() {

View file

@ -35,7 +35,6 @@ source_plugins() {
}
main() {
shared_set_tpm_path_constant
source_plugins
}
main

View file

@ -58,7 +58,6 @@ update_plugins() {
}
main() {
shared_set_tpm_path_constant
if [ "$1" == "all" ]; then
update_all
else