diff --git a/schedule.sh b/schedule.sh index 693e853..f0f9d16 100755 --- a/schedule.sh +++ b/schedule.sh @@ -1,22 +1,27 @@ #!/usr/bin/env bash -mynick=iVS +myname=iVS repo=fat0troll/lorchess tournament=autumn2013 +# Colors +green='\\033[01;32m' +red='\\033[01;31m' +restore='\\033[00m' + # Note that we use `"$@"' to let each command-line parameter expand to a # separate word. The quotes around `$@' are essential! # We need ARGS as the `eval set --' would nuke the return value of getopt. -args=`getopt --options n: --longoptions nick: -- "$@"` +args=`getopt --options p: --longoptions player: -- "$@"` # Note the quotes around `$ARGS': they are essential! eval set -- "$args" -if [[ $1 == -n ]] || [[ $1 == --nick ]]; then +if [[ $1 == -p ]] || [[ $1 == --player ]]; then name=$2 shift 3 else - name=$mynick + name=$myname shift fi @@ -26,6 +31,11 @@ for tour in $@; do tour=${tour:(-2)} url=https://raw.github.com/$repo/master/$tournament/tour_$tour/tour_info - curl -q --silent $url | egrep "Тур|Время|$name" - echo " ***" + + echo ">>>" + curl -q --silent $url | egrep "Тур|Время|$name" | while read line;do + # Colorize the player name + output=$(echo $line | sed "s/${name}/${red}${name}${restore}/g") + echo -e $output + done done