JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
17.41k stars 2.38k forks source link

Oh my posh becomes slow when kubectl is installed #1743

Closed andrerav closed 2 years ago

andrerav commented 2 years ago

Code of Conduct

What happened?

I followed the steps outlined here to configure my prompt. My profile.ps1 looks like this:

Import-Module oh-my-posh
oh-my-posh --init --shell pwsh --config ~\AppData\Local\Programs\oh-my-posh\themes\stelbent.minimal.omp.json | Invoke-Expression

The prompt looks nice and works as expected. However, after running any arbitrary command (including very simple things like echo) it takes a noticably long time before the prompt returns (about 0.2-1 seconds it seems, but it varies).

Based on the output from Write-PoshDebug it seems that the command kubectl is the culprit. If I remove kubectl from PATH the problem goes away.

Theme

The result is the same with most themes, it seems.

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Log output

╭─ powershell  Projects  羽9ms⠀                                                                                                                             11,16:15 
╰─ff Write-PoshDebug

Version: 7.14.1

Segments:

ConsoleTitle(false)  -   0 ms -
shell(true)          -   0 ms - ╭─ powershell
root(false)          -   0 ms -
path(true)           -   0 ms -  Projects
git(false)           -  11 ms -
executiontime(true)  -   0 ms -  羽9s 1ms⠀
node(false)          -   0 ms -
python(false)        -   0 ms -
java(false)          -   1 ms -
dotnet(false)        -   1 ms -
go(false)            -   0 ms -
rust(false)          -   0 ms -
dart(false)          -   0 ms -
angular(false)       -   0 ms -
julia(false)         -   0 ms -
ruby(false)          -   0 ms -
azfunc(false)        -   0 ms -
aws(false)           -   0 ms -
kubectl(false)       - 348 ms -
os(true)             -   1 ms -   
battery(false)       -   0 ms -
time(true)           -   0 ms -   11,16:15 
text(true)           -   0 ms - ╰─
exit(true)           -   0 ms - ff

Run duration: 368.4199ms

Cache path: C:\Users\[redacted]\AppData\Local/oh-my-posh
JanDeDobbeleer commented 2 years ago

@andrerav unfortunately that's just kubectl being slow. What you can do is make use of parse_kubeconfig to no longer do the kubectl call but let oh-my-posh parse the config manually.

andrerav commented 2 years ago

Great, thank you very much for that tip. My solution ended up being a custom theme where I removed the kubectl segment entirely.

github-actions[bot] commented 8 months ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.