Skip to content

Commit

Permalink
Fix #718 do not create HOME env var
Browse files Browse the repository at this point in the history
  • Loading branch information
rkeithhill committed Nov 30, 2019
1 parent 1e9587f commit 8870a64
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/Utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,14 @@ function Get-PromptPath {

$stringComparison = Get-PathStringComparison

# $HOME is defined by PowerShell on all platforms. If for some reason it isn't defined, use a fallback.
$homePath = if ($HOME) {$HOME} else {[System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::UserProfile)}

# Abbreviate path by replacing beginning of path with ~ *iff* the path is under the user's home dir
if ($abbrevHomeDir -and $currentPath -and !$currentPath.Equals($Home, $stringComparison) -and
$currentPath.StartsWith($Home, $stringComparison)) {
if ($abbrevHomeDir -and $currentPath -and !$currentPath.Equals($homePath, $stringComparison) -and
$currentPath.StartsWith($homePath, $stringComparison)) {

$currentPath = "~" + $currentPath.SubString($Home.Length)
$currentPath = "~" + $currentPath.SubString($homePath.Length)
}

return $currentPath
Expand Down
3 changes: 0 additions & 3 deletions src/posh-git.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ param([switch]$ForcePoshGitPrompt)
. $PSScriptRoot\GitTabExpansion.ps1
. $PSScriptRoot\TortoiseGit.ps1

if (!$Env:HOME) { $Env:HOME = "$Env:HOMEDRIVE$Env:HOMEPATH" }
if (!$Env:HOME) { $Env:HOME = "$Env:USERPROFILE" }

$IsAdmin = Test-Administrator

# Get the default prompt definition.
Expand Down
4 changes: 2 additions & 2 deletions test/DefaultPrompt.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Describe 'Default Prompt Tests - NO ANSI' {

Context 'Prompt with no Git summary' {
It 'Returns the expected prompt string' {
Set-Location $env:HOME -ErrorAction Stop
Set-Location $HOME -ErrorAction Stop
$res = [string](&$prompt *>&1)
$res | Should BeExactly "$(Get-PromptConnectionInfo)$(GetHomePath)> "
}
Expand Down Expand Up @@ -152,7 +152,7 @@ Describe 'Default Prompt Tests - ANSI' {

Context 'Prompt with no Git summary' {
It 'Returns the expected prompt string' {
Set-Location $env:HOME -ErrorAction Stop
Set-Location $HOME -ErrorAction Stop
$res = &$prompt
$res | Should BeExactly "$(Get-PromptConnectionInfo)$(GetHomePath)> "
}
Expand Down

0 comments on commit 8870a64

Please sign in to comment.