Posh-git: Setting variables without importing posh-git

Created on 24 Oct 2018  路  10Comments  路  Source: dahlbyk/posh-git

I am using posh-git and it auto loads when entering a directory that is using git.

I'd like to customize several module variables, without having to import the module in my profile since this drastically slows down starting powershell.

Is this possible?

# Microsoft.Powershell_profile.ps1
# enabling the following darastically slows down starting powershell

# Import-Module posh-git

# $GitPromptSettings.BeforeStatus = 'on '
# $GitPromptSettings.AfterStatus = ''

# enable this but makes pwsh load times slow!
# $GitPromptSettings.EnableStashStatus = $true

Thanks.

Area-PromptFunction Enhancement Performance

Most helpful comment

I have a PR pending that I think should help shave ~.5 secs off the load time on pwsh. Hopefully I can get the PR merged for the next beta.

All 10 comments

When I measure Import-Module posh-git I'm seeing about a 1 second load time which is something we should look into. Is this about the same slow down you're seeing? Also, what version of posh-git are you on? You can get that info if you run gmo posh-git after the module has been imported.

Unfortunately, what you're asking for will not work atm. Before we come up with yet another way to provide settings, I'd like to see if we can improve the module load time.

Yes it's about 1 second, which substantially slows down loading the already slow to start pwsh v6 shell. I'm running the latest version of posh git available from the gallery.

There are two "latest" available. Which one you got depends on whether or not you used the -AllowPrerelease flag with Install-Module.

> gmo posh-git

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0.0      posh-git                            {Add-PoshGitToProfile, Ad...

I have a PR pending that I think should help shave ~.5 secs off the load time on pwsh. Hopefully I can get the PR merged for the next beta.

any progress?

That PR made it into the current beta. It improved load time a little. There is another PR (#698) that is attempting to re-write our PSM1 file at build-time with all the dot-source files embedded into it (rather than dot-sourcing them). That is supposed to speed up load time a bit more.

Good to know. Yes powershell startup times are still a big problem for me. Any improvements here would for sure be welcome. Thanks for your work.

any status update here?

No progress on this particular issue. I'd rather atm focus on making the module import faster. In particular, we have a catch 22 situation here where you can't set the settings which is based on the type PoshGitPromptSettings which you don't have access to until after posh-git has been imported.

Was this page helpful?
0 / 5 - 0 ratings