aboutsummaryrefslogtreecommitdiff
path: root/plugins/tpm/scripts/source_plugins.sh
diff options
context:
space:
mode:
authorCody Hiar <codyfh@gmail.com>2017-02-13 09:54:26 -0700
committerCody Hiar <codyfh@gmail.com>2017-02-13 09:54:26 -0700
commit783ab79ab721593b0ac85ab4d8ea9b74fa5fe72e (patch)
tree03ac1d680ab401874ed95a78887c56d6eb268a61 /plugins/tpm/scripts/source_plugins.sh
parent2eede125238144e9d37cf856aaaeda3c5de5aab3 (diff)
Adding tpm
Diffstat (limited to 'plugins/tpm/scripts/source_plugins.sh')
-rwxr-xr-xplugins/tpm/scripts/source_plugins.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/plugins/tpm/scripts/source_plugins.sh b/plugins/tpm/scripts/source_plugins.sh
new file mode 100755
index 0000000..bb79c26
--- /dev/null
+++ b/plugins/tpm/scripts/source_plugins.sh
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+
+CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+HELPERS_DIR="$CURRENT_DIR/helpers"
+
+source "$HELPERS_DIR/plugin_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_plugins() {
+ local plugin plugin_path
+ local plugins="$(tpm_plugins_list_helper)"
+ for plugin in $plugins; do
+ plugin_path="$(plugin_path_helper "$plugin")"
+ silently_source_all_tmux_files "$plugin_path"
+ done
+}
+
+main() {
+ source_plugins
+}
+main