2014-05-18 22:35:55 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2015-08-03 15:40:50 +00:00
|
|
|
HELPERS_DIR="$CURRENT_DIR/helpers"
|
2014-05-18 22:35:55 +00:00
|
|
|
|
2015-08-03 15:40:50 +00:00
|
|
|
source "$HELPERS_DIR/plugin_functions.sh"
|
2014-05-18 22:35:55 +00:00
|
|
|
|
2014-08-30 15:16:28 +00:00
|
|
|
plugin_dir_exists() {
|
|
|
|
[ -d "$1" ]
|
|
|
|
}
|
|
|
|
|
2014-05-22 10:26:04 +00:00
|
|
|
# Runs all *.tmux files from the plugin directory.
|
|
|
|
# Files are ran as executables.
|
2014-05-18 22:35:55 +00:00
|
|
|
# No errors if the plugin dir does not exist.
|
|
|
|
silently_source_all_tmux_files() {
|
2015-08-03 13:18:26 +00:00
|
|
|
local plugin_path="$1"
|
2014-05-24 21:15:13 +00:00
|
|
|
local plugin_tmux_files="$plugin_path*.tmux"
|
2014-08-30 15:16:28 +00:00
|
|
|
if plugin_dir_exists "$plugin_path"; then
|
|
|
|
for tmux_file in $plugin_tmux_files; do
|
2014-11-18 22:12:10 +00:00
|
|
|
# if the glob didn't find any files this will be the
|
|
|
|
# unexpanded glob which obviously doesn't exist
|
|
|
|
[ -f "$tmux_file" ] || continue
|
2014-08-30 15:16:28 +00:00
|
|
|
# runs *.tmux file as an executable
|
|
|
|
$tmux_file >/dev/null 2>&1
|
|
|
|
done
|
|
|
|
fi
|
2014-05-18 22:35:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
source_plugins() {
|
2015-08-03 13:18:26 +00:00
|
|
|
local plugin plugin_path
|
2015-08-03 15:40:50 +00:00
|
|
|
local plugins="$(tpm_plugins_list_helper)"
|
2014-05-24 21:15:13 +00:00
|
|
|
for plugin in $plugins; do
|
2019-05-19 20:59:06 +00:00
|
|
|
IFS='#' read -ra plugin <<< "$plugin"
|
|
|
|
plugin_path="$(plugin_path_helper "${plugin[0]}")"
|
2015-08-03 13:18:26 +00:00
|
|
|
silently_source_all_tmux_files "$plugin_path"
|
2014-05-24 21:15:13 +00:00
|
|
|
done
|
2014-05-18 22:35:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
2014-05-24 21:15:13 +00:00
|
|
|
source_plugins
|
2014-05-18 22:35:55 +00:00
|
|
|
}
|
|
|
|
main
|