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 AbbreviateHomeDirectory setting #387

Merged
merged 3 commits into from
Feb 1, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/GitPrompt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ $global:GitPromptSettings = [pscustomobject]@{
DefaultPromptDebugSuffix = ' [DBG]$(''>'' * ($nestedPromptLevel + 1)) '
DefaultPromptEnableTiming = $false

AbbreviateHomeDirectory = $true
Copy link
Collaborator

@rkeithhill rkeithhill Jan 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change this to DefaultPromptAbbrevHomeDir or something with the DefaultPrompt prefix? Since this setting applies only to the posh-git default prompt.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After re-reading, this change only affects the default prompt, so sure.

Would DefaultPromptAbbreviateHomeDirectory be appropriate?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit long but still not the longest property name. :-) Folder is a bit shorter than Directory but I guess it doesn't matter that much.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the option, I personally prefer 'Directory', so unless you feel strongly about using Folder to save the three characters, I'd prefer to use 'Directory'.

I'll change to DefaultPromptAbbreviateHomeDirectory, and you can veto as necessary.


Debug = $false

BranchNameLimit = 0
Expand Down
2 changes: 1 addition & 1 deletion src/posh-git.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if (!$currentPromptDef -or ($currentPromptDef -eq $defaultPromptDef)) {
}

# Abbreviate path by replacing beginning of path with ~ *iff* the path is in the user's home dir
if ($currentPath -and $currentPath.StartsWith($Home, $stringComparison))
if ($GitPromptSettings.AbbreviateHomeDirectory -and $currentPath -and $currentPath.StartsWith($Home, $stringComparison))
{
$currentPath = "~" + $currentPath.SubString($Home.Length)
}
Expand Down