I noticed a couple of things that might help reduce the custom code you have to maintain, if you're interested.

The block that reduces the path such that the home is normalized to ~ - you can use the function from posh-git that does it for you: $currentPath = $GitPromptSettings.DefaultPromptPath.Expand().Text

There's a VSSetup PowerShell module that can be used to locate VS installs for 2017 (and, I think, 2019). It might be easier to use that than manually probe paths. Admittedly, I've only tried this on Windows.

The PowerShell Community Extensions (pscx) module has Import-VisualStudioVars that makes use of the VSSetup module and has support for the earlier versions of VS based on environment variables. That might also help.

Also, I found I could fairly consistently shave about 40 - 100ms off the rendering of the prompt by running the external commands (kubectl, sed, dotnet, etc.) in parallel using PowerShell runspaces. It makes the script more complicated since you have to separate the retrieval of the data from the rendering of the data, but the prompt feels a little faster. Like: