Skip to content

Instantly share code, notes, and snippets.

@yuta-aoyagi
Last active September 1, 2015 12:05
Show Gist options
  • Save yuta-aoyagi/b54ee98b24b6c619ff88 to your computer and use it in GitHub Desktop.
Save yuta-aoyagi/b54ee98b24b6c619ff88 to your computer and use it in GitHub Desktop.
gred: a filter emphasizing the given pattern
#!/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