Closed shanselman closed 3 years ago
Especially support for the \uE0A0
(branch) glyph in the Hack font. Ooh, I see you have easy access to that glyph with [Block]::Branch
.
I have already implemented this with my own PSGit module. You can import that, and use Get-GitStatusPowerLine
(there's a sample config file for PSGit in this repo).
I'm not happy with it, because it still uses the posh-git-style configuration which now seems clumsy...
I'm going to redo that this weekend after I change the nested block handling ...
I am not sure whether I will bother writing a Powerline function based on posh-git
-- it will probably depend on whether their module supports PowerShell Core or not...
Do you use posh-git for anything other than the prompt?
Yes! Tab completion. Posh-git tab completes branch names and first level commands e.g git clo<tab>
.
BTW, shouldn't we try to amass support behind Posh-Git as it seems to be the most popular PowerShell module for Git out there? Maybe that module can be updated to make it work with this module?? I managed to convince Dave to update Pester to better support the VSCode-PowerShell extension. Maybe we convince the Posh-Git folks to make some tweaks to support escape codes for hosts that support virtual terminals (instead of Write-Host -Fore/Back).
Are you serious, @rkeithhill? they have pull requests that have been open for four years. Good luck with that. I gave up on my attempt to synchronize their color settings with posh-hg after the pull request sat idle for a year.
I do not care about posh-git any more. It's a text-parser wrapper around the exe with an un-ending series of pull requests and issues that just get ignored...
If the module works on linux (I still haven't tried), I'll be happy to build a prompt function for it that returns PowerLine.Block
s, but no, I'm not going to try to get people to rally around it.
Granted they don't seem to be accepting many PRs (although one of mine did get accepted). However, the module has > 10,000 downloads from the PSGallery. I had chatted briefly with Keith Dahlby and he indicated he was looking for help. I just didn't have any spare cycles at the time with the work I've been doing on PSES and Plaster. Maybe I could put in a good word for you? :-)
Thanks @shanselman for looping me in on this.
@Jaykul's frustration with me is totally deserved — I simply haven't chosen to spend as much time on posh-git as its popularity warrants, particularly in addressing pain points that I don't experience myself (perf, shared config with posh-hg, etc). As @rkeithhill notes, I have started asking for help from those that express interest; that goes for anyone here as well. I don't wish to be a roadblock.
Since you have my attention, what do you need from posh-git here? I'm not sure what "whether their module supports PowerShell Core" means.
Re: Linux support: https://github.com/dahlbyk/posh-git/issues/302
@dahlbyk. Support for PowerShell Core means support the new open source version of PowerShell that runs on Linux, macOS and Windows. It is built upon .NET Core. There are differences between it and Windows PowerShell which runs on the full fledged .NET Framework (and only runs on Windows). That said, I'm not sure that is the first order of business (maybe the second though). First thing - I think (and I'm sure @Jaykul will correct me if I'm wrong) is to switch from Write-Host for displaying text with colors to ANSI codes on versions of PowerShell (5.x on Windows PowerShell and PowerShell Core). That will allow posh-git to compose with modules like this prompt customization module.
BTW thanks for your work on posh-git. Love it and have it on all my dev machines. Also, I'm about over the hump on a new module I've been working on (Plaster) so I will have time in October to help with posh-git (and would like to do so).
First thing - I think (and I'm sure @Jaykul will correct me if I'm wrong) is to switch from Write-Host for displaying text with colors to ANSI codes on versions of PowerShell (5.x on Windows PowerShell and PowerShell Core). That will allow posh-git to compose with modules like this prompt customization module.
As far as I know, all colored output is handled in one place: Write-Prompt
. Assuming we can reasonably establish if the current host supports ANSI codes, it seems like it shouldn't be too difficult to add ANSI support there?
More generally, I've never been particularly happy with how posh-git actually integrates into the prompt - replacing prompt
feels pretty hacky (and in the Chocolatey install it's even worse), so if there is a better way to handle this in newer versions of PowerShell (or a community convention I've missed), please let me know (c.f. https://github.com/dahlbyk/posh-git/issues/217).
@dahlbyk Determining support is easy. If this property $host.UI.SupportsVirtualTerminal
exists and is true, the host supports ANSI codes.
WIP at https://github.com/dahlbyk/posh-git/pull/304
PowerLine usage would be @{ text = { Write-VcsStatus } }
.
Cool!
replacing prompt feels pretty hacky
Yup but that's the only way. And that prompt function is a bit weird. It expects you to return a string of some sort - even if you use Write-Host to write all the prompt text. Common practice has been to return a string with a single space in it. For consoles that support ASNI color codes that simplifies to just returning a string with ANSI codes/text.
I’ve recently done https://github.com/dahlbyk/posh-git/pull/673, which improves Write‑GitPrompt
support for PowerLine blocks with custom background colours.
Yeah, I can confirm that you can use posh-git with PowerLine now -- I'm using it on my laptop at work because the team had standardized on it before I got there 😉
Specifically, with posh-git 1.0.0 what I do is this:
$global:GitPromptSettings = New-GitPromptSettings
$global:GitPromptSettings.BeforeStatus = ''
$global:GitPromptSettings.AfterStatus = ''
$global:GitPromptSettings.PathStatusSeparator = ''
$global:GitPromptSettings.BeforeStash.Text = "$(Text '&ReverseSeparator;')"
$global:GitPromptSettings.AfterStash.Text = "$(Text '&Separator;')"
Add-PowerLineBlock { Write-VcsStatus }
Support for posh-git would be so so special