kymsu2.sh

-option --all to run all scripts
This commit is contained in:
2021-12-14 11:43:12 +01:00
parent a4e9ed9053
commit afa77f865c

View File

@@ -12,7 +12,8 @@ if [[ "$1" == "-h" || "$1" == "--help" ]]; then
echo " -h, --help display this help" echo " -h, --help display this help"
echo " --nodistract no distract mode (no user interaction)" echo " --nodistract no distract mode (no user interaction)"
echo " --cleanup removing any older versions of installed formulae and clearing old downloads from the Homebrew download-cache" echo " --cleanup removing any older versions of installed formulae and clearing old downloads from the Homebrew download-cache"
echo " --npm_cleanup cleaning npm cache" echo " --npm_cleanup cleaning npm cache"
echo " --all run all scripts (by default, all except those start by _)"
echo echo
echo "Tips:" echo "Tips:"
echo " -prefix the plugin with _ to ignore it" echo " -prefix the plugin with _ to ignore it"
@@ -24,18 +25,19 @@ fi
echo "Please, grab a ☕️, KYMSU keep your working environment up to date!" echo "Please, grab a ☕️, KYMSU keep your working environment up to date!"
SCRIPTS_DIR=$HOME/.kymsu/plugins.d SCRIPTS_DIR=$HOME/.kymsu/plugins.d
#SCRIPTS_DIR=$(cat ~/.kymsu/path)/plugins.d
[[ $@ =~ "--all" ]] && all_plugins=true || all_plugins=false
if [ "$all_plugins" = false ]; then
# Tous sauf commençant par _ (les fichiers commençant par '_' ne sont pas pris en compte) "_*.sh"
list_plugins=$(find $SCRIPTS_DIR -maxdepth 1 -type f ! -name "_*" -a -name "*.sh" -a -perm +111 | sort)
else
# Tous (-a = ET; -perm +111 = exec)
list_plugins=$(find $SCRIPTS_DIR -maxdepth 1 -type f -name "*.sh" -a -perm +111 | sort)
fi
cd "$SCRIPTS_DIR" cd "$SCRIPTS_DIR"
# On boucle sur tous les fichiers du répertoire for script in $list_plugins; do
# (seuls les fichiers commençant par '_' ou '0' sont pris en compte) # le $@ permet de passer à chaque script les arguments passés à *ce* script
#for script in $(find . -name '[_0]*' -maxdepth 1 | sort); do $script $@
for script in $(find . -maxdepth 1 ! -name _\*.sh | sort); do
# si le fichier est exécutable et n'est pas un dossier
if [ -x "$SCRIPTS_DIR/$script" ] && [ -f "$SCRIPTS_DIR/$script" ]; then
# on lexécute ; le $@ permet de passer à chaque
# script les arguments passés à *ce* script
$SCRIPTS_DIR/$script $@
fi
done done