1
0
Fork 0
mirror of synced 2024-11-14 05:28:58 -05:00
tpm/scripts/source_plugins.sh
2014-11-19 11:12:10 +13:00

45 lines
1 KiB
Bash
Executable file

#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/shared_functions.sh"
plugin_dir_exists() {
[ -d "$1" ]
}
# Runs all *.tmux files from the plugin directory.
# Files are ran as executables.
# No errors if the plugin dir does not exist.
silently_source_all_tmux_files() {
local plugin_path=$1
local plugin_tmux_files="$plugin_path*.tmux"
if plugin_dir_exists "$plugin_path"; then
for tmux_file in $plugin_tmux_files; do
# if the glob didn't find any files this will be the
# unexpanded glob which obviously doesn't exist
[ -f "$tmux_file" ] || continue
# runs *.tmux file as an executable
$tmux_file >/dev/null 2>&1
done
fi
}
source_plugin() {
local plugin=$1
local plugin_path=$(shared_plugin_path "$plugin")
silently_source_all_tmux_files "$plugin_path"
}
source_plugins() {
local plugins=$(shared_get_tpm_plugins_list)
for plugin in $plugins; do
source_plugin "$plugin"
done
}
main() {
shared_set_tpm_path_constant
source_plugins
}
main