From b9a1695a61ef662d278566e596417922f3d79833 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Sat, 8 May 2021 10:45:44 +0200 Subject: [PATCH] Fix short path in prompt. --- .profile.d/ps1.bashrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 } -- 2.20.1