Remix.run Logo
▲ xorcist 2 hours ago

Not to rain on your fine snippet but you can use negative offsets to index from the end of the string:

  P="$PWD"
  [ ${#P} -gt $pwdmaxlen ] && P="$trunc_symbol${P: -$pwdmaxlen}"