-
-
Save yuta-aoyagi/b54ee98b24b6c619ff88 to your computer and use it in GitHub Desktop.
gred: a filter emphasizing the given pattern
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
#!/bin/sh | |
set -e | |
NAME=gred | |
err() { | |
echo "$@" >&2 | |
exit 1 | |
} | |
my_tput() { | |
tput "$@" || err "$NAME: failed \`tput $@'" | |
} | |
[ $# = 1 ] || err "usage: $NAME pattern" | |
RED=`my_tput setaf 1` | |
INV=`my_tput smso` | |
NORMAL=`my_tput sgr0` | |
sed -e "s/$1/$RED$INV&$NORMAL/g" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment