starship: Starship is slow on PowerShell in Windows
Current Behavior
Any prompt takes up to 2 seconds to display regardless of environment or current directory, without any modules enabled.
Expected Behavior
It should work way more faster
Additional context/Screenshots
~
❯ Measure-Command { starship explain }
Days : 0
Hours : 0
Minutes : 0
Seconds : 1
Milliseconds : 560
Ticks : 15604482
TotalDays : 1.80607430555556E-05
TotalHours : 0.000433457833333333
TotalMinutes : 0.02600747
TotalSeconds : 1.5604482
TotalMilliseconds : 1560.4482
~
❯ starship explain
Here's a breakdown of your prompt:
~ (45ms) - The current working directory
❯ (<1ms) - A character (usually an arrow) beside where the text is entered in your terminal
Possible Solution
Unfortunately I don’t know Rust yet and the only thing I was able to do is to build a binary and run it with trace logging enabled, but it doesn’t really help.
Environment
- Starship version: 0.47.0
- powershell version: 7.1.0
- Operating system: Windows 10.0.18363
- Terminal emulator: Windows Terminal
Relevant Shell Configuration
Invoke-Expression (&starship init powershell)
Starship Configuration
[git_status]
disabled = true
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 20 (8 by maintainers)
I have finally resolved the issue. It wasn’t starship prompt at all (: It was antivirus software. It has real-time protection and it’s triggered by starship and powershell binaries each time new prompt has to be displayed. The most tricky part is that you have to exclude two binaries from those checks:
Excluding just starship.exe doesn’t help even though
Measure-Command { starship explainstarts to show great timings. Remember to exclude pwsh.exe also!You can speed up startup in PowerShell a bit by using
&starship init powershell --print-full-init | Out-String | Invoke-Expressioninstead ofInvoke-Expression (&starship init powershell). (#1032 #2637)Edit: I made a PR (#2146) to improve performance in WSL by using windows starship for windows paths.
Modules are fast enough but loading the next prompt is always taking forever.
starship timingsaren’t accurate at all as to how fast the next prompt is loading, it is always > 1 second. It’s like it is runningstarship initafter every command or somethingWell wherever you’re getting the slowdown appears to be outside the modules, they don’t seem to have any issues.