#!/bin/bash
#########################################################
#                                                       #
# This is BashStyle-NG                                	#
#                                                       #
# Licensed under GNU GENERAL PUBLIC LICENSE v3          #
#                                                       #
# Copyright 2007 - 2011 Christopher Bratusek            #
#                                                       #
#########################################################

if [[ $enabcol == true ]]; then

colstyle=$(get_key color/style)

if [[ $colstyle == bright ]]; then \
	style="01"
elif [[ $colstyle == normal ]]; then \
	style="0"
elif [[ $colstyle == inverted ]]; then \
	style="7"
elif [[ $colstyle == dimmed ]]; then \
	style="02"
elif [[ $colstyle == underlined ]]; then \
	style="04"
fi

lblack="${style};30"
lred="${style};31"
lgreen="${style};32"
lyellow="${style};33"
lblue="${style};34"
lmagenta="${style};35"
lcyan="${style};36"
lwhite="${style};37"

if [[ $TERM != *xterm* ]]; then

	lcoldblue=$lblue
	lsmoothblue=$lblue
	liceblue=$lblue
	lturqoise=$lcyan
	lsmoothgreen=$lgreen
	lwinered=$lred
	lbrown=$lyellow
	lsilver=$lwhite
	locher=$lyellow
	lorange=$lyellow
	lpurple=$lmagenta
	lpink=$lmagenta
	lcream=$lmagenta

else

	lcoldblue="${style};38;5;33"
	lsmoothblue="${style};38;5;111"
	liceblue="${style};38;5;45"
	lturqoise="${style};38;5;50"
	lsmoothgreen="${style};38;5;42"
	lwinered="${style};38;5;637"
	lbrown="${style};38;5;684"
	lsilver="${style};38;5;761"
	locher="${style};38;5;690"
	lorange="${style};38;5;714"
	lpurple="${style};38;5;604"
	lpink="${style};38;5;213"
	lcream="${style};38;5;5344"

fi

export lblack lred lgreen lyellow lblue lmagenta lcyan lwhite lcoldblue lsmoothblue liceblue lturqoise
export lsmoothgreen lwinered lbrown lsilver locher lorange lpurple lpink lcream

eval _exec=$(get_key dircolors/exec)
eval _gen=$(get_key dircolors/generic)
eval _log=$(get_key dircolors/logs)
eval _deb=$(get_key dircolors/deb)
eval _rpm=$(get_key dircolors/rpm)
eval _dirs=$(get_key dircolors/dirs)
eval _jpg=$(get_key dircolors/jpeg)
eval _png=$(get_key dircolors/png)
eval _gif=$(get_key dircolors/gif)
eval _mp3=$(get_key dircolors/mp3)
eval _ogg=$(get_key dircolors/ogg)
eval _flac=$(get_key dircolors/flac)
eval _tar=$(get_key dircolors/tar)
eval _targz=$(get_key dircolors/targz)
eval _tarbz2=$(get_key dircolors/tarbz2)
eval _zip=$(get_key dircolors/zip)
eval _rar=$(get_key dircolors/rar)

_custom="$(get_key dircolors/custom)"

dbg_log export LS_COLORS="ex=$_exec:*=$_gen:*.log=$_log:*.deb=$_deb:*.rpm=$_rpm:di=$_dirs:*.jpg=$_jpg:*.png=$_png:*.gif=$_gif:\
*.mp3=$_mp3:*.ogg=$_ogg:*.flac=$_flac:*.tar=$_tar:*.tar.gz=$_targz:*.tar.bz2=$_tarbz2:*.zip=$_zip:*.rar=$_rar:$_custom"

dbg_msg $"LS_COLORS Setting: LS_COLORS" "$LS_COLORS"
dbg_msg $"LS_COLORS Loading: BashStyle-NG"
else	dbg_msg $"LS_COLORS Message: colors disabled!"
	dbg_msg $"LS_COLORS Message: not setting LS_COLORS"
	dbg_msg $"LS_COLORS Loading: BashStyle-NG"
	unset LS_COLORS
fi
