Along the same lines as with the work done for issue #386 it would be nice to more finely tune the path portion of the prompt. With older versions of posh-git I would typically hand edit my Profile to customize this but with the more extensible model through use of variables I think extending it this way will be cleaner and make it easier to setup a new custom environment up in a way that is less likely to break with updates.
Before:
C:\root\sub1\sub2\sub3\workingdir [develop ≡ +0 ~1 -0 !]>
After:
$GitPromptSettings.DefaultPromptPathTemplate = '$([System
.IO.Path]::GetFileName($currentPath))'
workingdir [develop ≡ +0 ~1 -0 !]>
Perhaps it would be more convenient to have a separate DefaultPromptFilePathTemplate and DefaultPromptPathTemplate just reduce the need for logical checks on the type of path for cases where the path is not a file system path.
Perhaps DefaultPromptAbbreviateHomeDirectory can be re-implemented in terms of this template.
Maybe it's more reasonable to provide a way way of supplying or overriding a function that provides the path string as a result instead of trying to embed this stuff into a expanded string template. I'm not sure what the common conventions are in the PowerShell world for providing for this type of extensibility model but I have some ideas of what may work.
I'll be happy to take a stab at contributing the change if it's something others may be interested in.
I really like this idea. Let's try a DefaultPromptPath (IMO drop "Template" in alignment with prefix/suffix settings) that defaults to '$(currentPath)' so folks have a starting point for customization.
Another option would be to skip the new setting and just have DefaultPromptPrefix default to '$(currentPath)'. It would be a breaking change for anyone who has already specified a DefaultPromptPrefix, but I'm not _super_ worried about this.
What about non file-system paths?
I'm not too worried about this. The cost of the default prompt putting together $currentPath is trivial, and if someone really wants super-fancy logic they can just define their own function to reference in the template.
What about home directory abbreviation?
No change here should be required since $currentPath will be available to the template.
I'll be happy to take a stab at contributing the change if it's something others may be interested in.
That would be great! Let me know if you need any assistance.
What about non file-system paths?
One option is to check $pwd.Provider.Name in poshGitPromptScriptBlock and if it isn't FileSystem, just use the $currentPath as it is defined in that ScriptBlock. I think most folks using this are probably only concerned about FileSystem paths. If anyone wants to control other provider paths, they can create a custom prompt function.
What about home directory abbreviation?
@dahlbyk So you would apply the DefaultPromptAbbreviateHomeDirectory after the $currentPath has been set by DefaultPromptPath (if the current location is on a FileSystem provider). Yeah, I like that.
I was actually thinking the other direction: let $currentPath always encapsulate our default/best prompt representation (abbreviated, if specified), and DefaultPromptPath (or DefaultPromptPrefix) would use that by default, but let folks manipulate that value (as in @jpierson's example) or do something like:
function Get-MyFancyPath ($path) {
if ($pwd.Provider.Name -ne 'FileSystem') { return "OMG! $path" }
"FileSystem:$path"
}
$GitPromptSettings.DefaultPromptPath = '$(Get-MyFancyPath $currentPath)'
Considering DefaultPromptAbbreviateHomeDirectory is not set by default, that should give them the full path in $currentPath. If we go this route, we should make a note in the poshGitPromptScriptBlock that user settings could be relying upon the variable name $currentPath and that it shouldn't be changed. That's a bit leaky but could live with it.
Another route to go (would need to test this), would be to inject this value via a parameter in a scriptblock e.g.:
$GitPromptSettings.DefaultPromptPath = { param($path) Get-MyFancyPath $path }
Then this setting would not be dependent upon an implementation detail of our default prompt function.
All good points, @rkeithhill. Note also that this whole discussion may be superseded in v2 by #340/#344 and possibly #345. In that context, I'm not overly concerned about churn in poshGitPromptScriptBlock breaking $currentPath (or we could rename as $path beforehand to simplify the "API").
We could also check the type of DefaultPromptPath (and Prefix/Suffix) to handle either strings or ScriptBlocks. Maybe overkill?
I more concerned about getting this right for v2. In v2, I would be inclined to support only scriptblocks when we need to pass parameters to the user's script. Seems like a better approach.
It just occurred to me one possible reason why my suggestion may not have as much validity as I originally envisioned it would. If the custom path only applies to git repository folders then the customization would only apply there. Generally customization I mentioned above is something I like to apply for the path regardless of whether the path is for source code or not. The same is true for using ~ in place of the home directory.
So I guess my question is whether these values would impact non-git directories or not? If so I suppose my proposal still stands but either way perhaps Posh-Git isn't the correct place to customize the path as shown in the prompt assuming that this is essentially the only part of the path that makes sense to always carry through un-modified in general. Is there a more general way to override the "path" portion of the prompt in a way that posh-git and possibly other tools could pick up on for prompt customization?
Is there a more general way to override the "path" portion of the prompt in a way that posh-git and possibly other tools could pick up on for prompt customization?
Nope. prompt isn't extensible; it can only be replaced. The default PS prompt is hard-coded to use $executionContext.SessionState.Path.CurrentLocation, and posh-git starts with the same value.
Another approach to implement this could be to consolidate the posh-git path logic into a Get-PromptPath function that we "install" using the same technique as the custom prompt. All you would have to do is define your own Get-PromptPath function to preempt/replace the posh-git default.
(Equivalent to $GitPromptSettings.DefaultPromptPath = '$(Get-PromptPath)'.)
I believe this will be adequately addressed by #520 for 1.0.

Most helpful comment
I really like this idea. Let's try a
DefaultPromptPath(IMO drop "Template" in alignment with prefix/suffix settings) that defaults to'$(currentPath)'so folks have a starting point for customization.Another option would be to skip the new setting and just have
DefaultPromptPrefixdefault to'$(currentPath)'. It would be a breaking change for anyone who has already specified aDefaultPromptPrefix, but I'm not _super_ worried about this.I'm not too worried about this. The cost of the default prompt putting together
$currentPathis trivial, and if someone really wants super-fancy logic they can just define their own function to reference in the template.No change here should be required since
$currentPathwill be available to the template.That would be great! Let me know if you need any assistance.