mirror of
https://github.com/tmux-plugins/tpm.git
synced 2024-12-04 18:58:49 +00:00
Stop using global variable for tpm path
This commit is contained in:
parent
79d90f90f7
commit
0e9b64ffc4
@ -11,6 +11,7 @@
|
|||||||
- 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
|
- refactor code that sets 'TMUX_PLUGIN_MANAGER_PATH' global env var
|
||||||
|
- stop using global variable for 'tpm path'
|
||||||
|
|
||||||
### v2.0.0, 2015-07-07
|
### v2.0.0, 2015-07-07
|
||||||
- enable overriding default key bindings
|
- enable overriding default key bindings
|
||||||
|
@ -43,7 +43,6 @@ update_plugin_prompt() {
|
|||||||
|
|
||||||
main() {
|
main() {
|
||||||
reload_tmux_environment
|
reload_tmux_environment
|
||||||
shared_set_tpm_path_constant
|
|
||||||
display_plugin_update_list
|
display_plugin_update_list
|
||||||
update_plugin_prompt
|
update_plugin_prompt
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ clean_plugins() {
|
|||||||
local plugins plugin plugin_directory
|
local plugins plugin plugin_directory
|
||||||
plugins="$(shared_get_tpm_plugins_list)"
|
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
|
[ -d "${plugin_directory}" ] || continue
|
||||||
plugin="$(shared_plugin_name "${plugin_directory}")"
|
plugin="$(shared_plugin_name "${plugin_directory}")"
|
||||||
case "${plugins}" in
|
case "${plugins}" in
|
||||||
@ -33,7 +33,6 @@ clean_plugins() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
shared_set_tpm_path_constant
|
|
||||||
ensure_tpm_path_exists
|
ensure_tpm_path_exists
|
||||||
clean_plugins
|
clean_plugins
|
||||||
exit_value_helper
|
exit_value_helper
|
||||||
|
@ -13,7 +13,7 @@ fi
|
|||||||
|
|
||||||
clone() {
|
clone() {
|
||||||
local plugin="$1"
|
local plugin="$1"
|
||||||
cd "$SHARED_TPM_PATH" &&
|
cd "$(tpm_path)" &&
|
||||||
GIT_TERMINAL_PROMPT=0 git clone --recursive "$plugin" >/dev/null 2>&1
|
GIT_TERMINAL_PROMPT=0 git clone --recursive "$plugin" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,14 +49,14 @@ install_plugins() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
verify_tpm_path_permissions() {
|
verify_tpm_path_permissions() {
|
||||||
|
local path="$(tpm_path)"
|
||||||
# check the write permission flag for all users to ensure
|
# check the write permission flag for all users to ensure
|
||||||
# that we have proper access
|
# that we have proper access
|
||||||
[ -w "$SHARED_TPM_PATH" ] ||
|
[ -w "$path" ] ||
|
||||||
echo_err "$SHARED_TPM_PATH is not writable!"
|
echo_err "$path is not writable!"
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
shared_set_tpm_path_constant
|
|
||||||
ensure_tpm_path_exists
|
ensure_tpm_path_exists
|
||||||
verify_tpm_path_permissions
|
verify_tpm_path_permissions
|
||||||
install_plugins
|
install_plugins
|
||||||
|
@ -2,14 +2,18 @@
|
|||||||
|
|
||||||
# using @tpm_plugins is now deprecated in favor of using @plugin syntax
|
# using @tpm_plugins is now deprecated in favor of using @plugin syntax
|
||||||
tpm_plugins_variable_name="@tpm_plugins"
|
tpm_plugins_variable_name="@tpm_plugins"
|
||||||
SHARED_TPM_PATH=""
|
|
||||||
|
|
||||||
# sets a "global variable" for the current file
|
_tpm_path() {
|
||||||
shared_set_tpm_path_constant() {
|
|
||||||
local string_path="$(tmux start-server\; show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)/"
|
local string_path="$(tmux start-server\; show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)/"
|
||||||
# manually expanding tilde or `$HOME` variable.
|
# manually expanding tilde or `$HOME` variable.
|
||||||
string_path="${string_path/#\~/$HOME}"
|
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() {
|
_tmux_conf_contents() {
|
||||||
@ -40,7 +44,7 @@ shared_plugin_name() {
|
|||||||
shared_plugin_path() {
|
shared_plugin_path() {
|
||||||
local plugin="$1"
|
local plugin="$1"
|
||||||
local plugin_name="$(shared_plugin_name "$plugin")"
|
local plugin_name="$(shared_plugin_name "$plugin")"
|
||||||
echo "${SHARED_TPM_PATH}${plugin_name}/"
|
echo "$(tpm_path)${plugin_name}/"
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin_already_installed() {
|
plugin_already_installed() {
|
||||||
@ -52,7 +56,7 @@ plugin_already_installed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ensure_tpm_path_exists() {
|
ensure_tpm_path_exists() {
|
||||||
mkdir -p "$SHARED_TPM_PATH"
|
mkdir -p "$(tpm_path)"
|
||||||
}
|
}
|
||||||
|
|
||||||
fail_helper() {
|
fail_helper() {
|
||||||
|
@ -35,7 +35,6 @@ source_plugins() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
shared_set_tpm_path_constant
|
|
||||||
source_plugins
|
source_plugins
|
||||||
}
|
}
|
||||||
main
|
main
|
||||||
|
@ -58,7 +58,6 @@ update_plugins() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
shared_set_tpm_path_constant
|
|
||||||
if [ "$1" == "all" ]; then
|
if [ "$1" == "all" ]; then
|
||||||
update_all
|
update_all
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user