Skip to content

Instantly share code, notes, and snippets.

@marco-m
Created April 14, 2020 09:38
Show Gist options
  • Save marco-m/ff87192de901fea27b4d2f53488958f6 to your computer and use it in GitHub Desktop.
Save marco-m/ff87192de901fea27b4d2f53488958f6 to your computer and use it in GitHub Desktop.
nice simple way to use colors in shell scripts
#! /bin/bash
# Courtesy of https://github.com/thought-machine/please/blob/master/bootstrap.sh
# See for example http://man7.org/linux/man-pages/man4/console_codes.4.html
# for more ANSI colors
function notice {
>&2 echo -e "\033[32m$1\033[0m"
}
function warn {
>&2 echo -e "\033[33m$1\033[0m"
}
# example usage
# note: requires the arguments to be quoted so that it becomes only 1
notice "as a notice: Building Please..."
warn "as a warn: Building Please..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment