Skip to content

Instantly share code, notes, and snippets.

@r3b
Created May 22, 2015 20:59
Show Gist options
  • Save r3b/897444c8e745d7315a4f to your computer and use it in GitHub Desktop.
Save r3b/897444c8e745d7315a4f to your computer and use it in GitHub Desktop.
Handy bash snippets
# 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