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
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
n=$((n+1))
done
- [ "${short:0:1}" = "~" ] || short="/$short"
+ [ "${short:0:1}" = "~" -o -z "$basename" ] || short="/$short"
echo "$short/$dirname"
return $1
}