]> arthur.barton.de Git - ConfigScripts.git/commitdiff
Shorten path displayed in default bash prompt, if necessary
authorAlexander Barton <alex@barton.de>
Wed, 21 Jul 2010 13:15:25 +0000 (15:15 +0200)
committerAlexander Barton <alex@barton.de>
Wed, 21 Jul 2010 13:15:25 +0000 (15:15 +0200)
sys/bashrc

index 8accc377173af15640adce041e596cb4b2486aca..1ab83d28977619d47ea1626b67e7bfe2913e8844 100644 (file)
@@ -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} " \