Created
November 11, 2018 09:28
-
-
Save gwpl/0b0e6c3363d8ef97939d3d5b04cd5541 to your computer and use it in GitHub Desktop.
bash coloring handy functions
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
# source: https://stackoverflow.com/a/20910449/544721 | |
norm="$(printf '\033[0m')" #returns to "normal" | |
bold="$(printf '\033[0;1m')" #set bold | |
red="$(printf '\033[0;31m')" #set red | |
boldred="$(printf '\033[0;1;31m')" #set bold, and set red. | |
somecommand | sed -e "s/someregexp/${boldred}&${norm}/g" # will color any occurence of someregexp in Bold red | |
printf "%s" "$red" ; locate something ; printf "%s" "$norm" # will color output of locate something in red | |
#I (ab)use printf "%s" "something", as it's more portable than echo,and easy to modify |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment