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

export pwdmaxlen=$(gconftool-2 --get /apps/bashstyle/pwdmaxlen)

export trunc_symbol=$(gconftool-2 --get /apps/bashstyle/pwdchar)

export dirchar=$(gconftool-2 --get /apps/bashstyle/dirchar)

export newsepacolor=$(bs-ng-parse-echo $sepacolor)

export newwdircolor=$(bs-ng-parse-echo $wdircolor)

export newpscoloror=$(bs-ng-parse-echo $pscolor)

if [[ $use_custom_prompt != true ]]; then
	if [[ $pstyle == separator || $pstyle == dirks || $pstyle == dot_prompt || $pstyle == sputnik ]]; then
		export supported=yes
	fi
fi

if [[ $pstyle == clock-ad ]]; then

	newPWD=$PWD

	if [[ "$fillsize" -lt "0" ]]; then
		cutt=3-${fillsize}
		newPWD="...$(echo -n $PWD | sed -e "s/\(^.\{$cutt\}\)\(.*\)/\2/")"
	fi
	
	if [[ $enabcol == true ]]; then
		export newPWD="${newPWD//\//$newsepacolor$dirchar$newwdircolor}"
	elif [[ $enabcol == false ]]; then
		export newPWD="${newPWD//\//$dirchar}"
	fi

elif [[ $enabcol == true && $supported == yes ]]; then

	if [ ${#PWD} -gt $pwdmaxlen ]; then
		export pwdoffset=$(( ${#PWD} - $pwdmaxlen ))
		export xPWD="$newpscoloror${trunc_symbol}${PWD:$pwdoffset:$pwdmaxlen}"
		export newPWD="${xPWD//\//$newsepacolor$dirchar$newwdircolor}"
	else
		export newPWD="${PWD//\//$newsepacolor$dirchar$newwdircolor}"
	fi

else

	if [ ${#PWD} -gt $pwdmaxlen ]; then
		export pwdoffset=$(( ${#PWD} - $pwdmaxlen ))
		export xPWD="${trunc_symbol}${PWD:$pwdoffset:$pwdmaxlen}"
		export newPWD="${xPWD//\//$dirchar}"
	else
		export newPWD="${PWD//\//$dirchar}"
	fi

fi

echo -e $newPWD
