From: Iain Patterson Date: Sat, 8 May 2021 08:45:44 +0000 (+0200) Subject: Fix short path in prompt. X-Git-Url: http://git.iain.cx/?p=profile.git;a=commitdiff_plain;h=b9a1695a61ef662d278566e596417922f3d79833;ds=sidebyside Fix short path in prompt. --- diff --git a/.profile.d/ps1.bashrc b/.profile.d/ps1.bashrc index 80ad1da..7c4cf2c 100644 --- a/.profile.d/ps1.bashrc +++ b/.profile.d/ps1.bashrc @@ -238,7 +238,7 @@ function __ps1_short() { local pwd=${PWD/#$home/\~} local dirtrim=${PROMPT_DIRTRIM//[^0-9]/} - if [ "${dirtrim:0:1}" = "0" ]; then + if [ "${dirtrim:0:1}" = "0" -o "$PWD" = "$HOME" ]; then echo "$pwd" return $1 fi @@ -265,7 +265,7 @@ function __ps1_short() { local n=1 local short= for component in $reversed; do - [ $n = 1 -a "$PWD" = "$pwd" ] || short="/$short" + [ $n = 1 ] || short="/$short" if [ $n -ge $dirtrim ]; then short="${component:0:1}$short" else @@ -274,7 +274,7 @@ function __ps1_short() { n=$((n+1)) done - [ "${short:0:1}" = "~" ] || short="/$short" + [ "${short:0:1}" = "~" -o -z "$basename" ] || short="/$short" echo "$short/$dirname" return $1 }