I am using Ubuntu and I am tired of this long prompts in bash when I am working with some deep directory hierarchy. So, I would like to tweak my PS1 to shorten the working d
Why not just use ${string:position:length}? You can do ${string:-$max_chars} to have the last ${max_chars} of the string.
${string:position:length}
${string:-$max_chars}
${max_chars}
note the negative value