From 15b24ab9d782a8e5683f305ec8b1c31849a64246 Mon Sep 17 00:00:00 2001 From: Elizabeth Date: Mon, 19 May 2025 23:03:02 -0700 Subject: initial commit --- tmux/.tmux/plugins/tpm/scripts/source_plugins.sh | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 tmux/.tmux/plugins/tpm/scripts/source_plugins.sh (limited to 'tmux/.tmux/plugins/tpm/scripts/source_plugins.sh') diff --git a/tmux/.tmux/plugins/tpm/scripts/source_plugins.sh b/tmux/.tmux/plugins/tpm/scripts/source_plugins.sh new file mode 100755 index 0000000..6381d54 --- /dev/null +++ b/tmux/.tmux/plugins/tpm/scripts/source_plugins.sh @@ -0,0 +1,42 @@ +#!/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 + IFS='#' read -ra plugin <<< "$plugin" + plugin_path="$(plugin_path_helper "${plugin[0]}")" + silently_source_all_tmux_files "$plugin_path" + done +} + +main() { + source_plugins +} +main -- cgit v1.2.3-70-g09d2