Mosh has this fully sorted too IMO: https://mosh.mit.edu
Mosh is for local echo of what you type when you have intermittent connectivity, whereas this lets you lazily calculate variables that might be included in your prompt (like "git status" on a large repository).