#!/bin/sh

# NEED_SYMLINK

# ***************************************************************************
# *   Copyright (C) 2013, Paul Lutus                                        *
# *                                                                         *
# *   This program is free software; you can redistribute it and/or modify  *
# *   it under the terms of the GNU General Public License as published by  *
# *   the Free Software Foundation; either version 2 of the License, or     *
# *   (at your option) any later version.                                   *
# *                                                                         *
# *   This program is distributed in the hope that it will be useful,       *
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
# *   GNU General Public License for more details.                          *
# *                                                                         *
# *   You should have received a copy of the GNU General Public License     *
# *   along with this program; if not, write to the                         *
# *   Free Software Foundation, Inc.,                                       *
# *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
# ***************************************************************************

# Created on Nov 16, 2013 1:45:34 AM

# purpose: syntax-highlight Android logcat listings

# reset default colors and exit on keyboard interrupt

trap '{ echo -e "\033[0m" ; exit 0; }' INT

declare -A cmap
cmap=([D]='38;5;75' [I]='38;5;40' [W]='38;5;166' [E]='38;5;196' [F]='38;5;201' )

while read line
do
  key=$(sed "s|.*\([DIWEF]\)/.*|\1|" <<< $line)
  echo -e "\033[${cmap[$key]}m$line\033[0m"
done