#!/bin/bash
#########################################################
#                                                       #
# This is BashStyle-NG                                  #
#                                                       #
# Licensed under GNU GENERAL PUBLIC LICENSE v3          #
#                                                       #
# Copyright Christopher Roy Bratušek                    #
#                                                       #
#########################################################

. gettext.sh
export TEXTDOMAIN="bashstyle-rc"

case ${1} in
    -h | --help)
        bashstyle-help -a "Christopher Roy Bratusek" -e "nano@jpberlin.de" -h "https://www.nanolx.org/"\
            -l "GNU GPL v3" -n "truncpwd" -s "$(eval_gettext "pretty print current directory")"\
            -v "${BSNG_VERSION}" -y "${BSNG_YEAR}"\
            -o "$(eval_gettext "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
