make-brew-installer.sh
-ajout d’options (courtes ou longues) pour choisir quoi installer: -b (brew) -c (casks) -m (mas)
This commit is contained in:
@@ -1,31 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
help=0
|
|
||||||
latest=0
|
|
||||||
verbose=0
|
|
||||||
status=0
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
cat <<-EOF
|
|
||||||
${0##*/} [options]
|
|
||||||
options:
|
|
||||||
-h show help dialog
|
|
||||||
-l reinstall packages with version "latest"
|
|
||||||
-v verbose output
|
|
||||||
EOF
|
|
||||||
exit "$status"
|
|
||||||
}
|
|
||||||
|
|
||||||
for opt
|
|
||||||
do case "$opt" in
|
|
||||||
'-h') usage ;;
|
|
||||||
'-l') latest=1 ;;
|
|
||||||
'-v') verbose=1 ;;
|
|
||||||
*) status=1 usage ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
echo "toto"
|
|
||||||
|
|
||||||
exit "$status"
|
|
||||||
@@ -1,17 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ "$1" == "-h" ]; then
|
|
||||||
echo "Create Homebrew 's packages and Casks installed list:"
|
|
||||||
echo " a brew-install.sh script is created next to this script..."
|
|
||||||
echo
|
|
||||||
echo "USAGE: brew-list [-p]"
|
|
||||||
echo
|
|
||||||
echo " -p just packages (not Casks)"
|
|
||||||
echo " -h display this help"
|
|
||||||
echo
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
<<COMMENT
|
<<COMMENT
|
||||||
underline=`tput smul`
|
underline=`tput smul`
|
||||||
nounderline=`tput rmul`
|
nounderline=`tput rmul`
|
||||||
@@ -30,11 +18,53 @@ echo -e "\033[32m Green World \033[0m"
|
|||||||
COMMENT
|
COMMENT
|
||||||
|
|
||||||
|
|
||||||
|
brew=0
|
||||||
|
casks=0
|
||||||
|
mas=0
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
|
||||||
|
cat <<EOM
|
||||||
|
Create Homebrew 's packages and Casks installed list:"
|
||||||
|
a brew-install.sh script is created next to this script..."
|
||||||
|
|
||||||
|
Usage: $(basename "$0") [OPTION]...
|
||||||
|
|
||||||
|
-b brew
|
||||||
|
-c casks
|
||||||
|
-m mas
|
||||||
|
-h display help
|
||||||
|
EOM
|
||||||
|
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts ":bcmh-:" option; do
|
||||||
|
|
||||||
|
if [ "$option" = "-" ] ; then
|
||||||
|
case $OPTARG in
|
||||||
|
help) option=h;;
|
||||||
|
brew) option=b;;
|
||||||
|
casks) option=c;;
|
||||||
|
mas) option=m;;
|
||||||
|
*) echo "Option $OPTARG inconnue";;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$option" in
|
||||||
|
b) brew=1;;
|
||||||
|
c) casks=1;;
|
||||||
|
m) mas=1;;
|
||||||
|
h) usage;;
|
||||||
|
?) echo "Option -$OPTARG inconnue"
|
||||||
|
usage;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
if [ -f brew-install.sh ]; then
|
if [ -f brew-install.sh ]; then
|
||||||
echo -e "The file \033[93mbrew-install.sh\033[0m already exist! We erase it."
|
echo -e "The file \033[93mbrew-install.sh\033[0m already exist! We erase it."
|
||||||
#echo "Le fichier ${bold}brew-install.sh${normal} existe déjà! On l'efface."
|
|
||||||
rm brew-install.sh
|
rm brew-install.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -82,23 +112,30 @@ else
|
|||||||
fi
|
fi
|
||||||
' >> brew-install.sh
|
' >> brew-install.sh
|
||||||
|
|
||||||
|
if [[ "$brew" -eq 1 ]] || [[ "$casks" -eq 1 ]] || [[ "$mas" -eq 1 ]]; then
|
||||||
echo -e "\n# Brew tap list.\n" >> brew-install.sh
|
echo -e "\n# Brew tap list.\n" >> brew-install.sh
|
||||||
echo -e "🍺 Get Homebrew \033[3m\033[93mtap\033[0m list"
|
echo -e "🍺 Get Homebrew \033[3m\033[93mtap\033[0m list"
|
||||||
brew tap | sed -e 's/^/brew tap /' >> brew-install.sh
|
brew tap | sed -e 's/^/brew tap /' >> brew-install.sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$brew" -eq 1 ]; then
|
||||||
echo -e "\n# Brew packages that I use alot.\n" >> brew-install.sh
|
echo -e "\n# Brew packages that I use alot.\n" >> brew-install.sh
|
||||||
echo -e "🍺 Get Homebrew \033[3m\033[93mpackages\033[0m installed list"
|
echo -e "🍺 Get Homebrew \033[3m\033[93mpackages\033[0m installed list"
|
||||||
brew list | sed -e 's/^/brew install /' >> brew-install.sh
|
brew list | sed -e 's/^/brew install /' >> brew-install.sh
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$1" != "-p" ]; then
|
if [ "$casks" -eq 1 ]; then
|
||||||
echo -e "\n# Some casks packages that I like.\n" >> brew-install.sh
|
echo -e "\n# Some casks packages that I like.\n" >> brew-install.sh
|
||||||
echo -e "🍺 Get Homebrew \033[3m\033[93mCask\033[0m installed list"
|
echo -e "🍺 Get Homebrew \033[3m\033[93mCask\033[0m installed list"
|
||||||
brew cask list | sed -e 's/^/brew cask install /' >> brew-install.sh
|
brew cask list | sed -e 's/^/brew cask install /' >> brew-install.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# https://github.com/mas-cli/mas
|
||||||
|
if [ "$mas" -eq 1 ]; then
|
||||||
echo -e "\n# Mac App Store applications list.\n" >> brew-install.sh
|
echo -e "\n# Mac App Store applications list.\n" >> brew-install.sh
|
||||||
echo -e "🍏 Get Mac App Store \033[3m\033[93mapplications\033[0m list"
|
echo -e "🍏 Get Mac App Store \033[3m\033[93mapplications\033[0m list"
|
||||||
mas list | awk '{print $1}' | sed -e 's/^/mas install /' >> brew-install.sh
|
mas list | awk '{print $1}' | sed -e 's/^/mas install /' >> brew-install.sh
|
||||||
|
fi
|
||||||
|
|
||||||
chmod +x brew-install.sh
|
chmod +x brew-install.sh
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user