tpm/scripts/shared_functions.sh

32 lines
865 B
Bash
Raw Normal View History

2014-05-18 22:35:55 +00:00
# shared functions and constants
tpm_plugins_variable_name="@tpm_plugins"
SHARED_TPM_PATH=""
# sets a "global variable" for the current file
shared_set_tpm_path_constant() {
2014-05-24 21:15:13 +00:00
SHARED_TPM_PATH=$(tmux show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)
2014-05-18 22:35:55 +00:00
}
shared_get_tpm_plugins_list() {
2014-05-24 21:15:13 +00:00
tmux show-option -gqv "$tpm_plugins_variable_name"
2014-05-18 22:35:55 +00:00
}
# Allowed plugin name formats:
# 1. "git://github.com/user/plugin_name.git"
# 2. "user/plugin_name"
shared_plugin_name() {
2014-05-24 21:15:13 +00:00
local plugin=$1
# get only the part after the last slash, e.g. "plugin_name.git"
local plugin_basename=$(basename "$plugin")
# remove ".git" extension (if it exists) to get only "plugin_name"
local plugin_name=${plugin_basename%.git}
echo $plugin_name
2014-05-18 22:35:55 +00:00
}
shared_plugin_path() {
2014-05-24 21:15:13 +00:00
local plugin=$1
local plugin_name=$(shared_plugin_name "$plugin")
echo "$SHARED_TPM_PATH$plugin_name/"
2014-05-18 22:35:55 +00:00
}