diff --git a/.bashrc b/.bashrc index df9c57e..a5e2e46 100644 --- a/.bashrc +++ b/.bashrc @@ -186,7 +186,12 @@ PS1="${debian_chroot:+($debian_chroot)}" # Short PWD, if it's to long. short_pwd() { - FIXED_PWD="${PWD/#$HOME/~}" + local FIXED_PWD=${PWD#$HOME} + if [ ${#FIXED_PWD} -le ${#PWD} ]; then + FIXED_PWD="~${FIXED_PWD}" + else + FIXED_PWD="${PWD}" + fi if [[ ${#FIXED_PWD} -gt $PWD_LENGTH ]]; then echo "${FIXED_PWD:0:$((4))}...${FIXED_PWD:$((${#PWD}-$PWD_LENGTH+7)):$(($PWD_LENGTH-7))}" else