Created
May 22, 2015 20:59
-
-
Save r3b/897444c8e745d7315a4f to your computer and use it in GitHub Desktop.
Handy bash snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Colorize your script output like it's 1985 | |
clrd() [ $# -lt 3 ]&& echo "Usage: $0 COLOR BOLD message\n" || printf "\033[%d;%dm%s\033[0;0m" $2 $1 "${@:3}"} | |
# echo with feeling | |
bold() { local MSG=$@;echo -e $(clrd 33 1 ">") $(clrd 30 1 "$MSG"); } | |
# Make a repeating string of characters | |
make_str() { [[ -z $2 ]] && $2="*"; [[ -z "$1" || "$1" -lt 1 ]] && echo || { echo -n "$2"; make_str $(( $1-1 )) "$2"; }; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment