mirror of
https://github.com/tmux-plugins/tpm.git
synced 2024-12-04 18:58:49 +00:00
Move all helpers to 'helpers/' dir
This commit is contained in:
parent
0e9b64ffc4
commit
9be7f975e9
@ -11,19 +11,19 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||||||
SCRIPTS_DIR="$CURRENT_DIR/../scripts"
|
SCRIPTS_DIR="$CURRENT_DIR/../scripts"
|
||||||
HELPERS_DIR="$SCRIPTS_DIR/helpers"
|
HELPERS_DIR="$SCRIPTS_DIR/helpers"
|
||||||
|
|
||||||
source "$SCRIPTS_DIR/shared_functions.sh"
|
source "$HELPERS_DIR/plugin_functions.sh"
|
||||||
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
||||||
source "$HELPERS_DIR/tmux_utils.sh"
|
source "$HELPERS_DIR/tmux_utils.sh"
|
||||||
|
|
||||||
display_plugin_update_list() {
|
display_plugin_update_list() {
|
||||||
local plugins="$(shared_get_tpm_plugins_list)"
|
local plugins="$(tpm_plugins_list_helper)"
|
||||||
tmux_echo "Installed plugins:"
|
tmux_echo "Installed plugins:"
|
||||||
tmux_echo ""
|
tmux_echo ""
|
||||||
|
|
||||||
for plugin in $plugins; do
|
for plugin in $plugins; do
|
||||||
# displaying only installed plugins
|
# displaying only installed plugins
|
||||||
if plugin_already_installed "$plugin"; then
|
if plugin_already_installed "$plugin"; then
|
||||||
local plugin_name="$(shared_plugin_name "$plugin")"
|
local plugin_name="$(plugin_name_helper "$plugin")"
|
||||||
tmux_echo " $plugin_name"
|
tmux_echo " $plugin_name"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
HELPERS_DIR="$CURRENT_DIR/helpers"
|
HELPERS_DIR="$CURRENT_DIR/helpers"
|
||||||
|
|
||||||
source "$CURRENT_DIR/shared_functions.sh"
|
source "$HELPERS_DIR/plugin_functions.sh"
|
||||||
|
source "$HELPERS_DIR/utility.sh"
|
||||||
|
|
||||||
if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
|
if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
|
||||||
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
||||||
@ -13,11 +14,11 @@ fi
|
|||||||
|
|
||||||
clean_plugins() {
|
clean_plugins() {
|
||||||
local plugins plugin plugin_directory
|
local plugins plugin plugin_directory
|
||||||
plugins="$(shared_get_tpm_plugins_list)"
|
plugins="$(tpm_plugins_list_helper)"
|
||||||
|
|
||||||
for plugin_directory in "$(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="$(plugin_name_helper "${plugin_directory}")"
|
||||||
case "${plugins}" in
|
case "${plugins}" in
|
||||||
*"${plugin}"*) : ;;
|
*"${plugin}"*) : ;;
|
||||||
*)
|
*)
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
# shared functions and constants
|
|
||||||
|
|
||||||
# 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"
|
||||||
|
|
||||||
@ -20,7 +18,7 @@ _tmux_conf_contents() {
|
|||||||
cat /etc/tmux.conf ~/.tmux.conf 2>/dev/null
|
cat /etc/tmux.conf ~/.tmux.conf 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_get_tpm_plugins_list() {
|
tpm_plugins_list_helper() {
|
||||||
# DEPRECATED: lists plugins from @tpm_plugins option
|
# DEPRECATED: lists plugins from @tpm_plugins option
|
||||||
echo "$(tmux start-server\; show-option -gqv "$tpm_plugins_variable_name")"
|
echo "$(tmux start-server\; show-option -gqv "$tpm_plugins_variable_name")"
|
||||||
|
|
||||||
@ -32,7 +30,7 @@ shared_get_tpm_plugins_list() {
|
|||||||
# Allowed plugin name formats:
|
# Allowed plugin name formats:
|
||||||
# 1. "git://github.com/user/plugin_name.git"
|
# 1. "git://github.com/user/plugin_name.git"
|
||||||
# 2. "user/plugin_name"
|
# 2. "user/plugin_name"
|
||||||
shared_plugin_name() {
|
plugin_name_helper() {
|
||||||
local plugin="$1"
|
local plugin="$1"
|
||||||
# get only the part after the last slash, e.g. "plugin_name.git"
|
# get only the part after the last slash, e.g. "plugin_name.git"
|
||||||
local plugin_basename="$(basename "$plugin")"
|
local plugin_basename="$(basename "$plugin")"
|
||||||
@ -41,34 +39,16 @@ shared_plugin_name() {
|
|||||||
echo "$plugin_name"
|
echo "$plugin_name"
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_plugin_path() {
|
plugin_path_helper() {
|
||||||
local plugin="$1"
|
local plugin="$1"
|
||||||
local plugin_name="$(shared_plugin_name "$plugin")"
|
local plugin_name="$(plugin_name_helper "$plugin")"
|
||||||
echo "$(tpm_path)${plugin_name}/"
|
echo "$(tpm_path)${plugin_name}/"
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin_already_installed() {
|
plugin_already_installed() {
|
||||||
local plugin="$1"
|
local plugin="$1"
|
||||||
local plugin_path="$(shared_plugin_path "$plugin")"
|
local plugin_path="$(plugin_path_helper "$plugin")"
|
||||||
[ -d "$plugin_path" ] &&
|
[ -d "$plugin_path" ] &&
|
||||||
cd "$plugin_path" &&
|
cd "$plugin_path" &&
|
||||||
git remote >/dev/null 2>&1
|
git remote >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure_tpm_path_exists() {
|
|
||||||
mkdir -p "$(tpm_path)"
|
|
||||||
}
|
|
||||||
|
|
||||||
fail_helper() {
|
|
||||||
local message="$1"
|
|
||||||
echo "$message" >&2
|
|
||||||
FAIL="true"
|
|
||||||
}
|
|
||||||
|
|
||||||
exit_value_helper() {
|
|
||||||
if [ "$FAIL" == "true" ]; then
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
}
|
|
17
scripts/helpers/utility.sh
Normal file
17
scripts/helpers/utility.sh
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
ensure_tpm_path_exists() {
|
||||||
|
mkdir -p "$(tpm_path)"
|
||||||
|
}
|
||||||
|
|
||||||
|
fail_helper() {
|
||||||
|
local message="$1"
|
||||||
|
echo "$message" >&2
|
||||||
|
FAIL="true"
|
||||||
|
}
|
||||||
|
|
||||||
|
exit_value_helper() {
|
||||||
|
if [ "$FAIL" == "true" ]; then
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
}
|
@ -3,7 +3,8 @@
|
|||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
HELPERS_DIR="$CURRENT_DIR/helpers"
|
HELPERS_DIR="$CURRENT_DIR/helpers"
|
||||||
|
|
||||||
source "$CURRENT_DIR/shared_functions.sh"
|
source "$HELPERS_DIR/plugin_functions.sh"
|
||||||
|
source "$HELPERS_DIR/utility.sh"
|
||||||
|
|
||||||
if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
|
if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
|
||||||
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
||||||
@ -29,7 +30,7 @@ clone_plugin() {
|
|||||||
# clone plugin and produce output
|
# clone plugin and produce output
|
||||||
install_plugin() {
|
install_plugin() {
|
||||||
local plugin="$1"
|
local plugin="$1"
|
||||||
local plugin_name="$(shared_plugin_name "$plugin")"
|
local plugin_name="$(plugin_name_helper "$plugin")"
|
||||||
|
|
||||||
if plugin_already_installed "$plugin"; then
|
if plugin_already_installed "$plugin"; then
|
||||||
echo_ok "Already installed \"$plugin_name\""
|
echo_ok "Already installed \"$plugin_name\""
|
||||||
@ -42,7 +43,7 @@ install_plugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
install_plugins() {
|
install_plugins() {
|
||||||
local plugins="$(shared_get_tpm_plugins_list)"
|
local plugins="$(tpm_plugins_list_helper)"
|
||||||
for plugin in $plugins; do
|
for plugin in $plugins; do
|
||||||
install_plugin "$plugin"
|
install_plugin "$plugin"
|
||||||
done
|
done
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
HELPERS_DIR="$CURRENT_DIR/helpers"
|
||||||
|
|
||||||
source "$CURRENT_DIR/shared_functions.sh"
|
source "$HELPERS_DIR/plugin_functions.sh"
|
||||||
|
|
||||||
plugin_dir_exists() {
|
plugin_dir_exists() {
|
||||||
[ -d "$1" ]
|
[ -d "$1" ]
|
||||||
@ -27,9 +28,9 @@ silently_source_all_tmux_files() {
|
|||||||
|
|
||||||
source_plugins() {
|
source_plugins() {
|
||||||
local plugin plugin_path
|
local plugin plugin_path
|
||||||
local plugins="$(shared_get_tpm_plugins_list)"
|
local plugins="$(tpm_plugins_list_helper)"
|
||||||
for plugin in $plugins; do
|
for plugin in $plugins; do
|
||||||
plugin_path="$(shared_plugin_path "$plugin")"
|
plugin_path="$(plugin_path_helper "$plugin")"
|
||||||
silently_source_all_tmux_files "$plugin_path"
|
silently_source_all_tmux_files "$plugin_path"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
HELPERS_DIR="$CURRENT_DIR/helpers"
|
HELPERS_DIR="$CURRENT_DIR/helpers"
|
||||||
|
|
||||||
source "$CURRENT_DIR/shared_functions.sh"
|
source "$HELPERS_DIR/plugin_functions.sh"
|
||||||
|
source "$HELPERS_DIR/utility.sh"
|
||||||
|
|
||||||
if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
|
if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
|
||||||
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
||||||
@ -18,7 +19,7 @@ shift
|
|||||||
|
|
||||||
pull_changes() {
|
pull_changes() {
|
||||||
local plugin="$1"
|
local plugin="$1"
|
||||||
local plugin_path="$(shared_plugin_path "$plugin")"
|
local plugin_path="$(plugin_path_helper "$plugin")"
|
||||||
cd "$plugin_path" &&
|
cd "$plugin_path" &&
|
||||||
GIT_TERMINAL_PROMPT=0 git pull &&
|
GIT_TERMINAL_PROMPT=0 git pull &&
|
||||||
GIT_TERMINAL_PROMPT=0 git submodule update --init --recursive
|
GIT_TERMINAL_PROMPT=0 git submodule update --init --recursive
|
||||||
@ -35,9 +36,9 @@ update() {
|
|||||||
update_all() {
|
update_all() {
|
||||||
echo_ok "Updating all plugins!"
|
echo_ok "Updating all plugins!"
|
||||||
echo_ok ""
|
echo_ok ""
|
||||||
local plugins="$(shared_get_tpm_plugins_list)"
|
local plugins="$(tpm_plugins_list_helper)"
|
||||||
for plugin in $plugins; do
|
for plugin in $plugins; do
|
||||||
local plugin_name="$(shared_plugin_name "$plugin")"
|
local plugin_name="$(plugin_name_helper "$plugin")"
|
||||||
# updating only installed plugins
|
# updating only installed plugins
|
||||||
if plugin_already_installed "$plugin_name"; then
|
if plugin_already_installed "$plugin_name"; then
|
||||||
update "$plugin_name"
|
update "$plugin_name"
|
||||||
@ -48,7 +49,7 @@ update_all() {
|
|||||||
update_plugins() {
|
update_plugins() {
|
||||||
local plugins="$*"
|
local plugins="$*"
|
||||||
for plugin in $plugins; do
|
for plugin in $plugins; do
|
||||||
local plugin_name="$(shared_plugin_name "$plugin")"
|
local plugin_name="$(plugin_name_helper "$plugin")"
|
||||||
if plugin_already_installed "$plugin_name"; then
|
if plugin_already_installed "$plugin_name"; then
|
||||||
update "$plugin_name"
|
update "$plugin_name"
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user