Because of the ssh-agent/windows update problems, I've updated to 1.0.0 beta posh-git but that seems to break the prompt integration with conemu (technically, cmder version 1.3.6 which uses conemu 180528).
The git part is placed at the end (after lambda sign in the second line) instead of after the direcotry in the first line (as it was with 0.7.3)
Interesting, I wouldn't expect the console host to have any impact, assuming it's correctly handling ANSI control sequences. Can you share a screenshot, or text that demonstrates what's happening? Are you customizing $GitPromptSettings at all?
Or are you using oh-my-posh?
using just posh-git, no customizations on the $GitPromptSettings. I should be able to share a screenshot around monday.
Can you post the output you get from running $PoshGitLastPrompt?

As for the output - runnign Write-Host $PoshGitLastPrompt outputs nothing.
Have you defined your own prompt function? If you're using the default posh-git prompt and you have 1.0.0-beta2 installed, you should see output from that variable like this:
~\GitHub\dahlbyk\posh-git [master ≡]> $PoshGitLastPrompt
~\GitHub\dahlbyk\posh-git $([char]27)[93m[$([char]27)[0m$([char]27)[96mmaster$([char]27)[0m$([char]27)[96m ≡$([char]27)[0m$([char]27)[93m]$([char]27)[0m>
You may have beta1 installed. You can check with this command (get-module posh-git).privatedata.psdata.prerelease. If you are still on beta1, run Update-Module posh-git -AllowPrerelease.
on beta2, output in 'normal' powershell terminal is $([char]27)[93m[$([char]27)[0m$([char]27)[96mmaster$([char]27)[0m$([char]27)[31m$([char]27)[49m +2$([char]27)[0m$([char]27)[31m$([char]27)[49m ~1$([char]27)[0m$([char]27)[31m$([char]27)[49m -0$([char]27)[0m$([char]27)[31m !$([char]27)[0m$([char]27)[93m]$([char]27)[0m> and the prompt is fine here.
Output in cmder still empty, still with the same issue.
Does $GitPromptSettings.AnsiConsole return false? Try setting $GitPromptSettings.AnsiConsole = $true.
FYI, we do check a ConEmu-specific environment variable for determining ANSI support:
I have to disagree. This broke how many of us in the community use it in conjunction with conemu because you completely destroyed backward compatibility from .73 to v1.0. Anything we had in our profiles and prompts broke, and as a DEV myself for the life of me, I'm still trying to figure out why you went in that direction.
For instance, in .73 there was an actual example including various functions (like setting console titlebar for git etc.). In version 1.0, however, you've now removed the example.ps1 for the profile and literally more than QUADRUPLED your lines of code to over 174 lines of code+text for a function named "Add-PoshGitToProfile" that literally does exactly what this SINGLE LINE of code does, no more - no less:
if ((Test-Path -LiteralPath $profilePath) -and ((Get-AuthenticodeSignature $profilePath).SignerCertificate) -and (!((@(Get-Content $profilePath -ErrorAction SilentlyContinue) -match 'posh-git').Count -gt 0))) { Add-Content -LiteralPath $profilePath -Value "`nImport-Module '$modulePath'" -Encoding UTF8}
It seems the profile addition functions/example in v1 now boils down (and is very limited to) "add import-module to your profile"...which also could have at that point probably even been left out of the code and mentioned in the readme. :)
So my question is, are we really saying in today's age of PoSH that the future direction of v1.0 can't at least continue to provide the handful of really useful services that were present in v7.3 and prior? And if not, can I ask why and what the show-stopping hurdles are, so perhaps we can contribute solutions to help?
I have to disagree.
What exactly in this issue are you disagreeing with? Also, Add-PoshGitToProfile was added in v0.7x, not v1.
can't at least continue to provide the handful of really useful services that were present in v7.3 and prior?
Which services (commands) are you referring to? We've mostly added functionality in v1:
CommandType Name Version Source
----------- ---- ------- ------
Function Add-PoshGitToProfile 1.0.0.0 posh-git
Function Expand-GitCommand 1.0.0.0 posh-git
Function Format-GitBranchName 1.0.0.0 posh-git
Function Get-GitBranchStatusColor 1.0.0.0 posh-git
Function Get-GitDirectory 1.0.0.0 posh-git
Function Get-GitStatus 1.0.0.0 posh-git
Function Get-PromptConnectionInfo 1.0.0.0 posh-git
Function Get-PromptPath 1.0.0.0 posh-git
Function prompt 1.0.0.0 posh-git
Function TabExpansion 1.0.0.0 posh-git
Function tgit 1.0.0.0 posh-git
Function Update-AllBranches 1.0.0.0 posh-git
Function Write-GitBranchName 1.0.0.0 posh-git
Function Write-GitBranchStatus 1.0.0.0 posh-git
Function Write-GitIndexStatus 1.0.0.0 posh-git
Function Write-GitStashCount 1.0.0.0 posh-git
Function Write-GitStatus 1.0.0.0 posh-git
Function Write-GitWorkingDirStatus 1.0.0.0 posh-git
Function Write-GitWorkingDirStatusSummary 1.0.0.0 posh-git
Function Write-Prompt 1.0.0.0 posh-git
Function Write-VcsStatus 1.0.0.0 posh-git
The big exception is the removal of the ssh functionality to the new posh-sshell module.
Well, if I do nothing else but upgrade from .73 to v1 like the OP above, and from the old profile example had this in my profile after of course a simple load of the module:
````
$Global:GitPromptSettings.EnableWindowTitle = "posh~git ~ <$SessionTitleName>"
....DO SOME OTHER LOADING.....
Start-SshAgent -Quiet
````
I am greeted with (mind you this is simply the removal of that method being populated by default and nothing to do with conemu) when the ONLY thing I changed was having ONLY 0.7.3 installed/loading on first screenshot, and simply upgraded it to either published 1.0.0.beta2, or even unzipped current Sept 15th build as screenshot #2 here:
Version 0.7.3:

Version 1.0.0.beta2 (either PSGallery or Github 9/15/2018)

As you can see, the screen turns red with this dumbed-down profile with any/all the SSHd commands prior to v1 no longer functioning at all, but things like the EnableWindowTitle not being properly initialized any longer and throwing errors. With the exception of this specific test vm not having the ssh-agent in place (easily fixed) 0.7.3 is totally free of any big ugly red terminating errors.
I can also demonstrate loading the default Posh console without any profile at all, loading only psreadline v2 and posh-git beta v1.0, and issuing the same commands as in this screenshot and still receiving the same glaring terminating errors so it is easily reproducible and not in the way I am calling it which was originally straight out of the provided example profile info. And since these errors are present when run in a straight Posh console without conemu even in the picture, so the conemu issue are simply snowballing from here.
Again, my point was not to upset you I was just trying to approach it logically that if you can afford to write and add almost 200 lines of text that is not "reusable" in any way and is hard-coded for a single purpose of adding a single hard-coded line of text (import-module posh-git) into the users' profile, then with that throughput it might not be unrealistic to think we could maybe find some ways to guard against breaking the users' of this module's profiles a little bit better and address these reproducible issues that tend to be a real PITA when they pop up after a simple "update-module". :)
my point was not to upset you
No worries and I'm not upset at all. Was just trying to figure out what you disagreed with. :-)
We plan to keep v0.7x around for a while so you don't have to upgrade to v1. Typically the nature of a major version change is indicative of one or more breaking changes. In order to do the following, it was necessary to make some breaking changes:
To fix your above errors - if you do not want to stick with v0.7x - install posh-sshell. That will provide you with the Start-SshAgent command. As for the EnableWindowTitle command, that changes to:
$GitPromptSettings.WindowTitle = "posh~git ~ <$SessionTitleName>"
Perhaps we should have a v0.7x to v1 migration guide?
A migration guide would certainly be a good idea. I do wonder if we could include anything in v1 to deprecate rather than break folks using v0 in a way we can't cleanly upgrade. Two examples:
The problem with adding the SSH "redirect info" commands is that when the user does install posh-sshell there will be conflicting commands. The one PowerShell picks will be based on import order. And when the user installs posh-sshell they'll have to use -AllowClobber.
Perhaps a better way to approach this is to use the CommandNotFoundAction e.g.:

The above is just a proof of concept. We'd have to add all the ssh commands to the list and also check to see if there's an existing CNFA handler and if so, then invoke it - returning whatever it returns.
CNFA could work, though it's weird that it's not built to be composable.
Could the shims check if posh-sshell is installed and pass-thru? Could we avoid exporting the shims if we detect it's installed?
Passthrus still incur the issues of duplicate commands i.e. import order and requires -AllowClobber. We can conditionally export the shims if posh-sshell is not installed.
Overall I think the CNFA approach is better - certainly much simpler to implement. The lack of composability is unfortunate but is no different than the TabExpansion function where we invoke the previous TabExpanion function (if there was one).
I'm running into a similar issue as @spooky was.
I was running Cmder on Windows 10, with PowerShell 6.0.1, posh-git 0.7.1.
Upgraded to PowerShell 6.1.0 and my prompt and output text ended up the same color. Upgraded to 0.7.3, noticed that posh-git 1.0.0 had PS Core support, so upgraded to 1.0.0 beta2.

I think these were the last debug steps before this issue swung on a slight tangent. :)
What does your prompt function look like? Execute get-command prompt | % definition and list the output here, if you don't mind.
Sorry for the delay:
$realLASTEXITCODE = $LASTEXITCODE
$host.UI.RawUI.WindowTitle = Microsoft.PowerShell.Management\Split-Path $pwd.ProviderPath -Leaf
PrePrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
CmderPrompt
Microsoft.PowerShell.Utility\Write-Host "`nλ " -NoNewLine -ForegroundColor "DarkGray"
PostPrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
$global:LASTEXITCODE = $realLASTEXITCODE
return " "
Hmm, that is not the default posh-git prompt function. I'm guessing some other module is providing your prompt function. It could be that it's hooking the posh-git prompt and then displaying it via the PostPrompt command invocation, which would explain why the posh-git status shows up after the Cmder prompt.
Do you get any source/module info if you execute: get-command PostPrompt?
| CommandType | Name | Version | Source |
| --- | --- | --- | --- |
| Function | PostPrompt | | |
I am using Cmder on top of ConEmu, but starting ConEmu directly results in the same behavior.
No changes to ConEmu/Cmder with the other changes I made.
What are the contents of PostPrompt - run Get-Command PostPrompt | % Definition.
Hmm. It appears to be nothing?
Thanks for checking. I have found that the prompt function is supplied by Cmder:
The posh-git status summary is displayed by the call to checkGit() which in turn calls the posh-git command Write-VcsStatus.
One change in posh-git v1 is to support VT sequences for hosts that support it. What this effectively means is that the Write-VcsStatus command will not use Write-Host to write the git status on a host that supports VT. In that case, it returns a string that contains the git status decorated with VT esc sequences to color various part of the status. So checkGit() returns a string but that string isn't displayed until after the prompt function returns which is also after all the Write-Host calls.
Try setting $GitPromptSettings.AnsiConsole = $false and see if that clears this up. When this setting is $false, posh-git reverts back to using Write-Host.
@dahlbyk If the above fix works, we could use the existence of $env:CMDER_ROOT to default AnsiConsole to $false. See https://github.com/cmderdev/cmder/blob/master/vendor/profile.ps1#L26
Or after looking at this: https://github.com/cmderdev/cmder/blob/master/vendor/profile.ps1#L69, maybe we should submit a PR to cmder to make it handle different versions of posh-git better. :-)
Thanks for digging deep! That appears to semi-resolve the issue:
Now:

Before I decided to update software that wasn't broken ;) :

Only differences are the presence of the PS (which may be a PS 6.1.x thing - I'm going to spend some time looking into it) and that it's per-session/reverts back to true (which I'm assuming is to be expected / it's checked and set on every startup).
Your suggestions sound good to me; please let me know how/if I can assist in anyway!
I don't work with PowerShell in any sort of advanced way, but for anyone in a similar situation, about_Prompts has information on customizing the PowerShell prompt.
Thanks. We're getting closer. That PS > usually happens when the prompt function returns no string e.g.:
function prompt { Write-Host "$pwd> " -NoNewline }
or there is an error generated in the prompt:
function prompt { Write-Host "$pwd> " -NoNewline; throw "oops"; " " }
I suspect it is the latter because line 125 of the Cmder prompt function is return " ". Could you open up a fresh Cmder console and after you get your first prompt, execute: $error.
Cmder error. :)
Get-command : The term 'vim' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At D:\Downloads\cmder\vendor\profile.ps1:44 char:5
- Get-command -Name "vim" -ErrorAction Stop >$null
~~~~~~~~~~~~- CategoryInfo : ObjectNotFound: (vim:String) [Get-Command], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
Unless you see something, I'll raise it as an error with them? https://github.com/cmderdev/cmder/blob/master/vendor/profile.ps1#L44
(I did upgrade Cmder to the current version from what I was at to see if that would resolve it; it did not.)
Hmm, but looking at that code, they catch the error and that code isn't executed within the prompt so that shouldn't be the cause of this problem. Keep in mind that the $error collection records all errors whether or not they were caught. Was there only that one error?
Good to know.
It was the only error reported. Went into a git repo and ran a few other commands that might verify that:

I think this is something we're doing in posh-git v1. I can replicate it with the following prompt function in a regular PowerShell console:
function prompt { $GitPromptSettings.AnsiConsole = 0; Write-VcsStatus; " " }
Now that I have a repro I should be able to figure out what is going on here. Hopefully we will have a beta3 out in a few weeks with a fix for this.
Excellent. Thank you again for helping to troubleshoot this!
And voila, I have figured it out. When AnsiConsole is set to 0 (off), Write-VcsStatus is returning an empty string. Returning an empty (or no) string from a prompt will result in PowerShell displaying PS> because it thinks that prompt function failed and the user should be given some default prompt. But when you return a collection of strings - the empty string returned by Write-VcsStatus and the " " - PowerShell gets confused and again, displays the default prompt e.g.:
function prompt { Write-Host "$pwd> " -NoNewline; ''; ' ' }
Results in this prompt C:\Users\hillr\Git\KLM> PS>. The good news is that I've already queued up a PR to fix this (#617). So I think the only additional thing we need to add is a check for $env:CMDER_ROOT that disables the AnsiConsole setting by default.
This should be fixed by #617 which should be available in 1.0.0-beta3.