From: Alexander Barton Date: Wed, 21 Jul 2010 13:15:25 +0000 (+0200) Subject: Shorten path displayed in default bash prompt, if necessary X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13e3d30b2c6f0ab690967babdeb185bc07d05335;p=ConfigScripts.git Shorten path displayed in default bash prompt, if necessary --- diff --git a/sys/bashrc b/sys/bashrc index 8accc37..1ab83d2 100644 --- a/sys/bashrc +++ b/sys/bashrc @@ -57,12 +57,17 @@ case "$TERM" in esac # Shell prompt +PS1_Path() { + P="${PWD/$HOME/~}" + echo "${P/???????????????????????????????*/${P:0:8}...${P: -20}}" +} + PS1="${COLOR_PREPOSTTXT}${PS1_BEGIN:-<}" [ "$UID" -eq 0 ] \ || PS1="${PS1}${COLOR_USER}\u${COLOR_AT}@" PS1="${PS1}${COLOR_HOST}\h" PS1="${PS1}${COLOR_COLON}:" -PS1="${PS1}${COLOR_PATH}\w" +PS1="${PS1}${COLOR_PATH}\$(PS1_Path)" PS1="${PS1}${COLOR_PREPOSTTXT}${PS1_END:->}${COLOR_RESET} " [ "$UID" -eq 0 ] \ && PS1="${PS1}${COLOR_PROMPT_ROOT}\\\$${COLOR_RESET} " \