1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2025-02-05 07:43:22 -08:00

add verbosity control to install script

This commit is contained in:
Connor Olding 2021-07-22 00:57:07 +02:00
parent 4adbbb0e27
commit b1f7cdd3f5

23
install
View file

@ -2,12 +2,17 @@
# this script is compatible with following shells: # this script is compatible with following shells:
# dash, bash, zsh # dash, bash, zsh
VERBOSE=1
[ -n "$ZSH_VERSION" -o -n "$BASH" ] || VERBOSE=0 # no colors for you
note() { note() {
printf "%s\n" "$@" local IFS=" "
printf "%s\n" "$*"
} }
warn() { warn() {
printf "%s\n" "$@" >&2 note "$@" >&2
} }
die() { die() {
@ -23,7 +28,6 @@ dotless() {
else else
REPLY="$1" REPLY="$1"
fi fi
#warn "$f -> $REPLY"
} }
backup() { backup() {
@ -79,11 +83,11 @@ softlink_pseudo() {
if [ -d "$d2" ]; then if [ -d "$d2" ]; then
if [ "$d1" != ".vim/bundle" ]; then # buggy on Windows if [ "$d1" != ".vim/bundle" ]; then # buggy on Windows
#warn $'\e[34m / \e[0m' "$d1 $d2" [ "${VERBOSE:-0}" -lt 1 ] || warn $'\e[34m / \e[0m' "$d1 $d2"
softlink_pseudo "$d1" "$d2" softlink_pseudo "$d1" "$d2"
fi fi
elif [ -f "$d2" ]; then elif [ -f "$d2" ]; then
#warn $'\e[34m * \e[0m' "$d1" [ "${VERBOSE:-0}" -lt 1 ] || warn $'\e[34m * \e[0m' "$d1"
hardlink "$d1" "$d2" hardlink "$d1" "$d2"
else else
die "i don't know how to pseudo-symlink $d2" die "i don't know how to pseudo-symlink $d2"
@ -104,9 +108,12 @@ find_new_files() {
if [ -d "$d2" ]; then if [ -d "$d2" ]; then
find_new_files "$d1" "$d2" find_new_files "$d1" "$d2"
elif [ ! "$d1" -ef "$d2" ]; then elif [ ! "$d1" -ef "$d2" ]; then
#warn "new destination file. consider manually moving it:" if [ "${VERBOSE:-0}" -lt 1 ]; then
#warn $'\e[32m + \e[0m' "$d1" warn " + $d1"
warn " + $d1" else
#warn "new destination file. consider manually moving it:"
warn $'\e[32m + \e[0m' "$d1"
fi
fi fi
done done
} }