Option -s
-option --nodistract (ou -n) pour exécuter les scripts sans interaction. -option -s 'script' pour exécuter 1 seul script (i.e -s homebrew, -s node, -s pip...)
This commit is contained in:
81
kymsu2.sh
81
kymsu2.sh
@@ -1,6 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
|
||||
italic="\033[3m"
|
||||
underline="\033[4m"
|
||||
ita_under="\033[3;4m"
|
||||
bgd="\033[1;4;31m"
|
||||
red="\033[1;31m"
|
||||
bold="\033[1m"
|
||||
bold_ita="\033[1;3m"
|
||||
box="\033[1;41m"
|
||||
reset="\033[0m"
|
||||
|
||||
function showHelp() {
|
||||
echo -e "\033[93m\033[1maltKymsu\033[0m"
|
||||
echo ""
|
||||
echo "alt Keep Your macOs Stuff Updated"
|
||||
@@ -9,25 +19,59 @@ if [[ "$1" == "-h" || "$1" == "--help" ]]; then
|
||||
echo "USAGE: kymsu2"
|
||||
echo
|
||||
echo "Commandes: "
|
||||
echo " -h, --help display this help"
|
||||
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 " --npm_cleanup cleaning npm cache"
|
||||
echo " --all run all scripts (by default, all except those start by _)"
|
||||
echo " -h, --help display this help"
|
||||
echo " -n, --nodistract no distract mode (no user interaction)"
|
||||
echo " -c, --cleanup removing any older versions of installed formulae and clearing old downloads from the Homebrew download-cache"
|
||||
#echo " --npm_cleanup cleaning npm cache"
|
||||
echo " -s $script run only the script given in argument"
|
||||
echo " -a, --all run all scripts (by default, all except those start by _)"
|
||||
echo
|
||||
echo "Tips:"
|
||||
echo " -prefix the plugin with _ to ignore it"
|
||||
echo " -see Settings section on top of each plug-in"
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
# exit 0
|
||||
}
|
||||
|
||||
echo "Please, grab a ☕️, KYMSU keep your working environment up to date!"
|
||||
all_plugins=false
|
||||
no_distract=false
|
||||
brew_cleanup=false
|
||||
|
||||
while getopts "hncs: a-:" opt
|
||||
do
|
||||
case $opt in
|
||||
-) case "${OPTARG}" in
|
||||
help) showHelp; exit;;
|
||||
nodistract) no_distract=true;;
|
||||
cleanup) brew_cleanup=true;;
|
||||
all) all_plugins=true;;
|
||||
*)
|
||||
echo "Unknow option '--${OPTARG}'" >&2
|
||||
exit -1;;
|
||||
esac;;
|
||||
h) showHelp; exit;;
|
||||
n) no_distract=true;;
|
||||
c) brew_cleanup=true;;
|
||||
s) one_script="${OPTARG}";;
|
||||
a) all_plugins=true;;
|
||||
*)
|
||||
echo "Unknow option '-$opt'" >&2
|
||||
exit -1;;
|
||||
esac
|
||||
done
|
||||
|
||||
#shift "$((OPTIND-1))"
|
||||
|
||||
SCRIPTS_DIR=$HOME/.kymsu/plugins.d
|
||||
|
||||
[[ $@ =~ "--all" ]] && all_plugins=true || all_plugins=false
|
||||
if [ "$all_plugins" = false ]; then
|
||||
# -n : non vide
|
||||
if [ -n "$one_script" ]; then
|
||||
# Un seul script
|
||||
list_plugins=$(find $SCRIPTS_DIR -maxdepth 1 -type f -name "*$one_script.sh" -a -perm +111)
|
||||
[ -z "$list_plugins" ] && echo -e "❗️ No named plugin ${italic}$one_script${reset}" && exit -1
|
||||
|
||||
# [[ $@ =~ "--all" ]] && all_plugins=true || all_plugins=false
|
||||
elif [ "$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
|
||||
@@ -37,7 +81,22 @@ fi
|
||||
|
||||
cd "$SCRIPTS_DIR"
|
||||
|
||||
<<COMMENT
|
||||
echo "$list_plugins"
|
||||
|
||||
echo "all args: $@"
|
||||
echo ""
|
||||
echo "script: $one_script"
|
||||
echo ""
|
||||
COMMENT
|
||||
|
||||
|
||||
echo "Please, grab a ☕️, KYMSU keep your working environment up to date!"
|
||||
echo ""
|
||||
|
||||
for script in $list_plugins; do
|
||||
# le $@ permet de passer à chaque script les arguments passés à *ce* script
|
||||
$script $@
|
||||
done
|
||||
|
||||
shift "$((OPTIND-1))"
|
||||
|
||||
@@ -16,7 +16,7 @@ display_info=true
|
||||
declare -a do_not_update=('')
|
||||
|
||||
# No distract mode (no user interaction)
|
||||
[[ $@ =~ "--nodistract" ]] && no_distract=true || no_distract=false
|
||||
[[ $@ =~ "-nodistract" || $@ =~ "-n" ]] && no_distract=true || no_distract=false
|
||||
|
||||
#
|
||||
###############################################################################################
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# https://guides.rubygems.org/what-is-a-gem/
|
||||
|
||||
# No distract mode
|
||||
[[ $@ =~ "--nodistract" ]] && no_distract=true || no_distract=false
|
||||
[[ $@ =~ "-nodistract" || $@ =~ "-n" ]] && no_distract=true || no_distract=false
|
||||
|
||||
italic="\033[3m"
|
||||
underline="\033[4m"
|
||||
|
||||
@@ -15,7 +15,8 @@ display_info=true
|
||||
declare -a cask_to_not_update=()
|
||||
|
||||
# No distract mode (no user interaction)(Casks with 'latest' version number won't be updated)
|
||||
[[ $@ =~ "--nodistract" ]] && no_distract=true || no_distract=false
|
||||
#[[ $@ =~ "--nodistract" ]] && no_distract=true || no_distract=false
|
||||
[[ $@ =~ "-nodistract" || $@ =~ "-n" ]] && no_distract=true || no_distract=false
|
||||
|
||||
# Some Casks have auto_updates true or version :latest. Homebrew Cask cannot track versions of those apps.
|
||||
# 'latest=true' force Homebrew to update those apps.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# https://github.com/welcoMattic/kymsu
|
||||
|
||||
# No distract mode (no user interaction)
|
||||
[[ $@ =~ "--nodistract" ]] && no_distract=true || no_distract=false
|
||||
[[ $@ =~ "-nodistract" || $@ =~ "-n" ]] && no_distract=true || no_distract=false
|
||||
|
||||
testing=1
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ display_info=true
|
||||
|
||||
# No distract mode (no user interaction)
|
||||
|
||||
[[ $@ =~ "--nodistract" ]] && no_distract=true || no_distract=false
|
||||
[[ $@ =~ "-nodistract" || $@ =~ "-n" ]] && no_distract=true || no_distract=false
|
||||
|
||||
# Set ls_color to '' for output nvm list in default colors, else '--no-colors'
|
||||
# ls_color='--no-colors'
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
display_info=true
|
||||
|
||||
# No distract mode (no user interaction)
|
||||
[[ $@ =~ "--nodistract" ]] && no_distract=true || no_distract=false
|
||||
[[ $@ =~ "-nodistract" || $@ =~ "-n" ]] && no_distract=true || no_distract=false
|
||||
|
||||
# Also add module for prevent to update it.
|
||||
declare -a do_not_update=('')
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
display_info=true
|
||||
|
||||
# No distract mode (no user interaction)
|
||||
[[ $@ =~ "--nodistract" ]] && no_distract=true || no_distract=false
|
||||
[[ $@ =~ "-nodistract" || $@ =~ "-n" ]] && no_distract=true || no_distract=false
|
||||
|
||||
# Display dependancies on updated pakages / casks
|
||||
#[[ $@ =~ "--depend" ]] && display_depend=false || display_depend=true
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# https://github.com/welcoMattic/kymsu
|
||||
|
||||
# No distract mode (no user interaction)
|
||||
[[ $@ =~ "--nodistract" ]] && no_distract=true || no_distract=false
|
||||
[[ $@ =~ "-nodistract" || $@ =~ "-n" ]] && no_distract=true || no_distract=false
|
||||
|
||||
# Upgrade --include-injected
|
||||
injected=true
|
||||
@@ -53,7 +53,7 @@ pipx-outdated() {
|
||||
done < <( pipx list | grep -o 'package.*,' | tr -d ',' | cut -d ' ' -f 2- )
|
||||
}
|
||||
|
||||
|
||||
# https://github.com/avantrec/soco-cli/blob/master/CHANGELOG.txt
|
||||
|
||||
pipx-outdated
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ admin=false
|
||||
#add module to do_not_update array
|
||||
declare -a do_not_update=()
|
||||
|
||||
#[[ $@ =~ "-nodistract" || $@ =~ "-n" ]] && no_distract=true || no_distract=false
|
||||
|
||||
if [[ $1 == "--nodistract" ]] || [[ $no_distract == true ]]; then
|
||||
no_distract=true
|
||||
prompt=
|
||||
|
||||
Reference in New Issue
Block a user