mirror of
https://github.com/correl/dotfiles.git
synced 2024-12-18 03:00:11 +00:00
[provisioning] Add color output
This commit is contained in:
parent
5b458a188a
commit
530f031678
1 changed files with 20 additions and 8 deletions
28
provision.sh
28
provision.sh
|
@ -7,6 +7,17 @@ RECIPES=$(ls $RECIPE_PATH|grep -v '^_' | sort)
|
|||
INSTALL=()
|
||||
STACK=()
|
||||
|
||||
if test -t 1; then
|
||||
ncolors=$(tput colors)
|
||||
if test -n "$ncolors" && test $ncolors -ge 8; then
|
||||
bold="$(tput bold)"
|
||||
dim="$(tput dim)"
|
||||
normal="$(tput sgr0)"
|
||||
red="$(tput setaf 1)"
|
||||
green="$(tput setaf 2)"
|
||||
fi
|
||||
fi
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-D|--debug)
|
||||
|
@ -70,7 +81,7 @@ function _run {
|
|||
echo "$msg..."
|
||||
$@
|
||||
fi
|
||||
echo "done."
|
||||
echo "${green}done.${normal}"
|
||||
}
|
||||
|
||||
function _recipe {
|
||||
|
@ -83,15 +94,17 @@ function _recipe {
|
|||
recipe="$1"
|
||||
path="${RECIPE_PATH}"
|
||||
else
|
||||
echo "Could not load recipe '$1'" >&2
|
||||
echo "${bold}${red}Could not load recipe '$1'${normal}" >&2
|
||||
exit 1
|
||||
fi
|
||||
STACK+=("$1")
|
||||
pushd "$path"
|
||||
echo "-- Recipe '${STACK[@]}' --"
|
||||
pushd "$path" >/dev/null
|
||||
echo "${dim}-- Recipe [${STACK[@]}]'${normal}"
|
||||
source "./${recipe}"
|
||||
echo "-- Recipe '${STACK[@]}' --"
|
||||
popd
|
||||
popd >/dev/null
|
||||
unset 'STACK[-1]'
|
||||
echo "${dim}-- Recipe [${STACK[@]}]${normal}"
|
||||
|
||||
}
|
||||
|
||||
USER=${USER:-$(whoami)}
|
||||
|
@ -102,12 +115,11 @@ if [ -z "${INSTALL[@]}" ]; then
|
|||
fi
|
||||
|
||||
|
||||
echo "-- Provisioning [${INSTALL[@]}] --"
|
||||
for recipe in "${INSTALL[@]}"; do
|
||||
_recipe $recipe
|
||||
done
|
||||
|
||||
echo "Finished"
|
||||
echo "${green}Finished${normal}"
|
||||
if [ -n "$RESTART_SHELL" ]; then
|
||||
echo "Restarting shell."
|
||||
exec $SHELL
|
||||
|
|
Loading…
Reference in a new issue