Skip to content

Write-VcsStatus behaving differently #612

@codedog

Description

@codedog
  • posh-git version/path: 1.0.0.0 beta2x C:\source\posh-git\src
  • PowerShell version: 5.1.17134.228
  • git version 2.18.0.windows.1
  • OS: Microsoft Windows NT 10.0.17134.0

Issue Description

I have a custom multi-lines prompt that used to work with v0.6.1.20160330 of posh-git. The git status stays on the first line. The second line contains just the right angle bracket. Now I have installed it on a new machine, and git status is appearing in the second line.

Here's the content of my profile script:

if(!(Test-Path function:\TabExpansion)) { New-Item function:\Global:TabExpansion -value '' | Out-Null }

function Test-Administrator {
    $user = [Security.Principal.WindowsIdentity]::GetCurrent();
    (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}

function prompt {
    $realLASTEXITCODE = $LASTEXITCODE

    Write-Host

    if (Test-Administrator) {  # Use different username if elevated
        Write-Host "^" -NoNewline -ForegroundColor White
    }

    Write-Host "$ENV:USERNAME@" -NoNewline -ForegroundColor DarkYellow
    Write-Host "$ENV:COMPUTERNAME" -NoNewline -ForegroundColor Magenta

    if ($s -ne $null) {  # color for PSSessions
        Write-Host " (`$s: " -NoNewline -ForegroundColor DarkGray
        Write-Host "$($s.Name)" -NoNewline -ForegroundColor Yellow
        Write-Host ") " -NoNewline -ForegroundColor DarkGray
    }

    Write-Host ":" -NoNewline -ForegroundColor DarkGray
    Write-Host $($(Get-Location) -replace ($env:USERPROFILE).Replace('\','\\'), "~") -NoNewline -ForegroundColor Blue
    Write-Host ":" -NoNewline -ForegroundColor DarkGray
    Write-Host (Get-Date -Format "d-MMM HH:mm:ss") -NoNewline -ForegroundColor DarkMagenta
    Write-Host ":" -NoNewline -ForegroundColor DarkGray

    $global:LASTEXITCODE = $realLASTEXITCODE

    Write-VcsStatus

    Write-Host ""

    return "> "
}

function which($command) {
  get-command $command | Format-Table Path
}

Set-Alias which gcm

Import-Module 'C:\source\posh-git\src\posh-git.psd1'

I have somewhat limited understanding of Powershell and can't remember how I cobbled up that prompt. What I was trying to achieve there is an updated timestamp in the prompt every time a command is executed.

Any ideas why Write-VcsStatus now inserts a newline before it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions