Merge pull request #6765 from EricFromCanada/shell-ohai

shell commands: colourize messages
This commit is contained in:
Mike McQuaid 2019-11-22 09:05:16 +00:00 committed by GitHub
commit a5550aa9a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 6 deletions

View File

@ -26,8 +26,17 @@ esac
# Higher depths mean this command was invoked by another Homebrew command. # Higher depths mean this command was invoked by another Homebrew command.
export HOMEBREW_COMMAND_DEPTH=$((HOMEBREW_COMMAND_DEPTH + 1)) export HOMEBREW_COMMAND_DEPTH=$((HOMEBREW_COMMAND_DEPTH + 1))
ohai() {
if [[ -t 1 && -z "$HOMEBREW_NO_COLOR" ]] # check whether stdout is a tty.
then
echo -e "\\033[34m==>\\033[0m \\033[1m$*\\033[0m" # blue arrow and bold text
else
echo "==> $*"
fi
}
onoe() { onoe() {
if [[ -t 2 ]] # check whether stderr is a tty. if [[ -t 2 && -z "$HOMEBREW_NO_COLOR" ]] # check whether stderr is a tty.
then then
echo -ne "\\033[4;31mError\\033[0m: " >&2 # highlight Error with underline and red color echo -ne "\\033[4;31mError\\033[0m: " >&2 # highlight Error with underline and red color
else else

View File

@ -36,11 +36,11 @@ homebrew-update-reset() {
do do
[[ -d "$DIR/.git" ]] || continue [[ -d "$DIR/.git" ]] || continue
cd "$DIR" || continue cd "$DIR" || continue
echo "==> Fetching $DIR..." ohai "Fetching $DIR..."
git fetch --force --tags origin git fetch --force --tags origin
echo echo
echo "==> Resetting $DIR..." ohai "Resetting $DIR..."
git checkout --force -B master origin/master git checkout --force -B master origin/master
echo echo
done done

View File

@ -87,7 +87,7 @@ fetch() {
temporary_path="$CACHED_LOCATION.incomplete" temporary_path="$CACHED_LOCATION.incomplete"
mkdir -p "$HOMEBREW_CACHE" mkdir -p "$HOMEBREW_CACHE"
[[ -n "$HOMEBREW_QUIET" ]] || echo "==> Downloading $VENDOR_URL" >&2 [[ -n "$HOMEBREW_QUIET" ]] || ohai "Downloading $VENDOR_URL" >&2
if [[ -f "$CACHED_LOCATION" ]] if [[ -f "$CACHED_LOCATION" ]]
then then
[[ -n "$HOMEBREW_QUIET" ]] || echo "Already downloaded: $CACHED_LOCATION" >&2 [[ -n "$HOMEBREW_QUIET" ]] || echo "Already downloaded: $CACHED_LOCATION" >&2
@ -107,7 +107,7 @@ fetch() {
if [[ ! -f "$temporary_path" ]] if [[ ! -f "$temporary_path" ]]
then then
[[ -n "$HOMEBREW_QUIET" ]] || echo "==> Downloading $VENDOR_URL2" >&2 [[ -n "$HOMEBREW_QUIET" ]] || ohai "Downloading $VENDOR_URL2" >&2
"$HOMEBREW_CURL" "${curl_args[@]}" "$VENDOR_URL2" -o "$temporary_path" "$HOMEBREW_CURL" "${curl_args[@]}" "$VENDOR_URL2" -o "$temporary_path"
fi fi
@ -180,7 +180,7 @@ install() {
fi fi
safe_cd "$VENDOR_DIR" safe_cd "$VENDOR_DIR"
[[ -n "$HOMEBREW_QUIET" ]] || echo "==> Pouring $(basename "$VENDOR_URL")" >&2 [[ -n "$HOMEBREW_QUIET" ]] || ohai "Pouring $(basename "$VENDOR_URL")" >&2
tar "$tar_args" "$CACHED_LOCATION" tar "$tar_args" "$CACHED_LOCATION"
safe_cd "$VENDOR_DIR/portable-$VENDOR_NAME" safe_cd "$VENDOR_DIR/portable-$VENDOR_NAME"