Last active
May 18, 2017 16:29
-
-
Save thiagoh/4fe827bb16500a8e4fe2a5ee8ea395cf to your computer and use it in GitHub Desktop.
Colored tail -f
This file contains hidden or 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
#!/bin/bash | |
macos="\x1B" | |
linux="\033" | |
marker=$linux | |
if echo $(uname -a) | grep -q -i "darwin"; then | |
marker=$macos | |
fi | |
green="$marker[0;32m" | |
unset="$marker[0m" | |
symbols=";:,.<>?/\$~!@#$%^&*()+_-" | |
cat - | gsed -re " | |
s/(INFO)(.+)/$green\1$unset\2/gI; | |
s/(WARN)(.+)/$marker[0;35m\1$unset\2/gI; | |
s/(ERROR)(.+)/$marker[1;31m\1$unset\2/gI; | |
s/([a-z0-9$symbols]+)=([a-z0-9$symbols]+)/$green\1$unset=\2/gI; | |
" |
This file contains hidden or 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
#!/bin/bash | |
# http://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux | |
# http://misc.flogisoft.com/bash/tip_colors_and_formatting | |
# Black 0;30 Dark Gray 1;30 | |
# Red 0;31 Light Red 1;31 | |
# Green 0;32 Light Green 1;32 | |
# Brown/Orange 0;33 Yellow 1;33 | |
# Blue 0;34 Light Blue 1;34 | |
# Purple 0;35 Light Purple 1;35 | |
# Cyan 0;36 Light Cyan 1;36 | |
# Light Gray 0;37 White 1;37 | |
macos="\x1B" | |
linux="\033" | |
marker=$linux | |
if echo $(uname -a) | grep -q -i "darwin"; then | |
marker=$macos | |
fi | |
# echo $marker; exit; | |
green="$marker[0;32m" | |
unset="$marker[0m" | |
symbols=";:,.<>?/\$~!@#$%^&*()+_-" | |
mystr="Error [05-18|11:20:09] Starting P2P Error\n | |
eRROR [05-18|11:20:09] Starting P2P eRROR\n | |
ERROR [05-18|11:20:09] Starting P2P ERROR\n | |
INFO [05-18|11:20:09] Starting P2P INFO\n | |
WarN [05-18|11:20:09] Starting P2P WarN\n | |
WARN [05-18|11:20:09] Starting P2P WARN\n | |
INFO [05-18|11:20:09] Loaded most recent local full block number=0 hash=d4e567…cb8fa3 td=17179869184\n | |
INFO [05-18|11:20:09] Loaded most recent local fast block number=0 hash=d4e567…cb8fa3 td=17179869184\n | |
INFO [05-18|11:20:09] Starting P2P networking\n | |
INFO [05-18|11:20:11] RLPx listener up self=enode://0aad1c4e232d0ca6933eed9ab14e4cd83a038c7be4e68a539a1eae761dfdbd5359c084fc426badbd34f6987ac882195da74d09f17a5c33e896e9aae180e2a2a5@[::]:30303\n | |
INFO [05-18|11:20:11] IPC endpoint opened: /Users/thiagoh/Library/Ethereum/geth.ipc\n | |
INFO [05-18|11:21:17] New wallet appeared url=keystore:///Users/thiagoh/dev/b… status=Locked\n | |
INFO [05-18|11:25:45] Got interrupt, shutting down...\n | |
INFO [05-18|11:25:45] IPC endpoint closed: /Users/thiagoh/Library/Ethereum/geth.ipc\n | |
INFO [05-18|11:25:45] Blockchain manager stopped\n | |
INFO [05-18|11:25:45] Stopping Ethereum protocol\n | |
INFO [05-18|11:25:45] Ethereum protocol stopped\n | |
INFO [05-18|11:25:45] Transaction pool stopped\n | |
INFO [05-18|11:25:45] Database closed database=/Users/thiagoh/dev/blockchain/solidity-experiments/.ethereum_private/geth/chaindata\n | |
" | |
# echo -e $mystr | gsed -re " | |
# s/(INFO)(.+)/$green\1$unset\2/gI; | |
# s/(WARN)(.+)/$marker[0;35m\1$unset\2/gI; | |
# s/(ERROR)(.+)/$marker[1;31m\1$unset\2/gI; | |
# s/([a-z0-9$symbols]+)=([a-z0-9$symbols]+)/$green\1$unset=\2/gI; | |
# " | |
cat - | gsed -re " | |
s/(INFO)(.+)/$green\1$unset\2/gI; | |
s/(WARN)(.+)/$marker[0;35m\1$unset\2/gI; | |
s/(ERROR)(.+)/$marker[1;31m\1$unset\2/gI; | |
s/([a-z0-9$symbols]+)=([a-z0-9$symbols]+)/$green\1$unset=\2/gI; | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment