Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to abbreviate home directory in prompt #386

Closed
shawmanz32na opened this issue Jan 31, 2017 · 12 comments
Closed

Add option to abbreviate home directory in prompt #386

shawmanz32na opened this issue Jan 31, 2017 · 12 comments

Comments

@shawmanz32na
Copy link

Currently, posh-git abbreviates my home directory to ~ in the prompt. By default, PowerShell prints out the whole path, which I prefer.

PS C:\Users\kshaw> becomes ~> with posh-git

After upgrading recently (thanks to Github for Windows), I noticed that my home directory is now abbreviated, and went looking for a GitPromptSetting that would allow me to turn off the abbreviation, but to no avail.

I'd like to see an AbbreviateHomeDirectory (or similar) setting in the GitPromptSettings that would allow me to enable or disable this home directory abbreviation.

@rkeithhill
Copy link
Collaborator

Seems reasonable. Using ~ is a common convention (borrowed) from Bash/Linux, where the prompt width can be shortened a bit.

@JayBazuzi
Copy link
Collaborator

Why is this a post-git request? isn't putting the CWD in the prompt outside of the scope of posh-git?

@rkeithhill
Copy link
Collaborator

posh-git 0.7.0, when it releases, will set the user's prompt with one that displays Git status summary info. It will not do this if the user has their own custom prompt function. We get so many questions about - I installed posh-git and then I imported it and I still don't see Git status summary info in my prompt. :-(

@JayBazuzi
Copy link
Collaborator

That makes sense, thanks @rkeithhill .

@rkeithhill
Copy link
Collaborator

@JayBazuzi But your question makes me wonder if the default for $GitPromptSettings.DefaultPromptAbbreviateHomeDirectory should be $false instead of $true. Hmm....

@JayBazuzi
Copy link
Collaborator

JayBazuzi commented Jan 31, 2017

~ is not just a *nix convention, it's part of PowerShell. You can do:

 PS> cd ~

So don't feel like you're pulling in a foreign notion.

@shawmanz32na
Copy link
Author

I'm familiar with the ~ convention, just personally prefer the powershell default. I don't mind the feature, I just wish it was configurable, hence the issue.

@rkeithhill Our thoughts align. As a user, I thought it strange that posh-git changed my prompt. As a matter of fact, I suspected that something was seriously broken when I didn't see my default prompt (I expected the additional git summary, just not the changes to my existing prompt, and it took me a little while to figure out it was a feature, not a bug. In the pending pull request, I defaulted to $true only because it wouldn't change the current functionality, which I presumed was the way it is for a reason. However, if there are many others like me that are caught off-gaurd by the change, printing the default prompt (instead of the abbreviated prompt) by default might be a good idea. I'd vote that the abbreviation be turned off by default.

@rkeithhill
Copy link
Collaborator

Let me think about the default value for the setting and get @dahlbyk opinion. Setting it to false would probably be the "safer" way to go.

@rkeithhill
Copy link
Collaborator

rkeithhill commented Feb 1, 2017

While we are at it, should we add a DefaultPromptPrefix setting that defaults to 'PS '? With this setting, the posh-git default prompt, would look just like the PowerShell default prompt except when in a Git repo. Then it would have the Git status summary inserted between the path and the > char. And if anyone wants to reclaim those three chars, they can set $GitPromptSettings.DefaultPromptPrefix = ''.

@dahlbyk
Copy link
Owner

dahlbyk commented Feb 1, 2017

While we are at it, should we add a DefaultPromptPrefix setting that defaults to 'PS '? With this setting, the posh-git default prompt, would look just like the PowerShell default prompt except when in a Git repo. Then it would have the Git status summary inserted between the path and the > char. And if anyone wants to reclaim those three chars, they can set $GitPromptSettings.DefaultPromptPrefix = ''.

I'm inclined to go the other direction, at least until 1.0: support DefaultPromptPrefix such that it's possible to mimic the default prompt, but have it default to empty for consistency with posh-git 0.6 and earlier. Maybe I'm overestimating folks' attachment to "the way things have been"? Would be curious how many people actually notice any of these details. Sigh.

@rkeithhill
Copy link
Collaborator

have it default to empty for consistency with posh-git 0.6 and earlier

Sounds good. I'll submit a PR for that tonight.

@rkeithhill
Copy link
Collaborator

PR submitted #393

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants