Living on the edge: truncating the path on your PS1

TL;DR I didn&rsquo;t like how the default zsh prompt truncation works. My solution, used in my own custom-made prompt (fully supported by promptinit ), uses a custom precmd hook to dynamically determine the terminal&rsquo;s available width. Instead of blind chopping, my custom logic ensures human-readable truncation by following simple rules: it always preserves the home directory (∼) and the…