Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting variables without importing posh-git #635

Open
musm opened this issue Oct 24, 2018 · 11 comments
Open

Setting variables without importing posh-git #635

musm opened this issue Oct 24, 2018 · 11 comments

Comments

@musm
Copy link

musm commented Oct 24, 2018

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
Copy link
Collaborator

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
Copy link
Author

musm commented Oct 26, 2018

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
Copy link
Collaborator

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

@musm
Copy link
Author

musm commented Oct 26, 2018

> gmo posh-git

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

@rkeithhill
Copy link
Collaborator

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
Copy link
Author

musm commented Oct 10, 2019

any progress?

@rkeithhill
Copy link
Collaborator

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
Copy link
Author

musm commented Oct 11, 2019

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
Copy link
Author

musm commented Mar 19, 2020

any status update here?

@rkeithhill
Copy link
Collaborator

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
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants