From 13e3d30b2c6f0ab690967babdeb185bc07d05335 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Wed, 21 Jul 2010 15:15:25 +0200 Subject: [PATCH] Shorten path displayed in default bash prompt, if necessary --- sys/bashrc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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} " \ -- 2.39.2