dahlbyk / posh-git

A PowerShell environment for Git
http://dahlbyk.github.io/posh-git/
MIT License
7.62k stars 799 forks source link

Setting variables without importing posh-git #635

Open musm opened 5 years ago

musm commented 5 years ago

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.

rkeithhill commented 5 years ago

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.

musm commented 5 years ago

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.

rkeithhill commented 5 years ago

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

musm commented 5 years ago
> gmo posh-git

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0.0      posh-git                            {Add-PoshGitToProfile, Ad...
rkeithhill commented 5 years ago

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.

musm commented 4 years ago

any progress?

rkeithhill commented 4 years ago

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.

musm commented 4 years ago

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.

musm commented 4 years ago

any status update here?

rkeithhill commented 4 years ago

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.

craigktreasure commented 2 years ago

@musm I'm curious how you auto load the module in a git directory. The time it takes to initialize the module is just too long. Sometimes it takes 5+ seconds for me. I've been using 1.0.0. Just updated to 1.1.0.