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

case ${1} in
	-h | --help)
		bsng-help -a "Christopher Roy Bratusek" -e "nano@jpberlin.de" -h "http://www.nanolx.org/"\
			-l "GNU GPL v3" -n "truncpwd" -s "pretty print current directory" -v "${BSNG_VERSION}" -y "${BSNG_YEAR}"\
			-o "none:|--"
	;;

	* )

		[[ ! ${dirchar} ]] && dirchar="/"
		[[ ! ${trunc_symbol} ]] && trunc_symbol="«"
		[[ ! ${trunc_length} ]] && trunc_length=1

		if [[ ${pwdmaxlen} != 0 && ${#PWD} -gt ${pwdmaxlen} ]]; then
			pwdoffset=$(( ${#PWD} - ${pwdmaxlen} ))
			xPWD="${ecolor_ps}${trunc_symbol}${PWD:${pwdoffset}:${pwdmaxlen}}"
			newPWD="${xPWD//\//${ecolor_separator}${dirchar}${ecolor_wdir}}"
		else
			newPWD="${PWD//\//${ecolor_separator}${dirchar}${ecolor_wdir}}"
		fi

		echo -e $newPWD
	;;
esac
