oh-my-posh is slow in Windows bash Environment (mingw64/git bash) #3787
Replies: 6 comments 14 replies
-
@fantasydr this has to be something else blocking the execution as I can't reproduce this at all, nor has this been reported before (and there's a lot of people using git bash unfortunately). The command itself: |
Beta Was this translation helpful? Give feedback.
-
Thank you for your prompt response. I've inspected my environment and found nothing unusual, as PowerShell integration functions perfectly. Except the 'get millis' command, the 'print' command is also slow, taking 110ms to complete when executed directly in PowerShell. I presume oh-my-posh integration doesn't use this command for every PowerShell command, only during initialization. However, in bash, the 'print' command is called for each command, significantly slowing down the bash shell:
Everything is stored on an SSD, so I'm confident that disk I/O is not the issue. Since you can't reproduce this problem in your bash environment, I will investigate what is causing the slowdown in 'oh-my-posh.exe' execution on my machine. Thank you again for this software! I will share my findings if I discover anything. |
Beta Was this translation helpful? Give feedback.
-
I tried to time the command on two of my computers (windows10/m.2 SSD/no virus scanner/AMD 3900x and 3700x with 32G mem) This is so weird... |
Beta Was this translation helpful? Give feedback.
-
@fantasydr the print command is executed equally on PowerShell and bash, even more in PowerShell when using a transient prompt. I'm pretty sure something is slowing down execution. And for the record, I'm not saying this isn't a possible bug, but I do want to rule out any known suspects and I need a reproducible scenario. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hello, I noticed that virtually any command is taking "a bit more" than a in standard git bash. Aside from this, what is really slow is going back to the prompt, you see the command output and then you have to wait another 300/400ms for showing the prompt. I already excluded oh-my-posh from the AV (before that, it took seconds to show the prompt, so I'm sure it is actually disabled!). I specify that this happens even outside a git repo and the time inside one is not affected noticeably, at least with small repos. I want to point out that, on the other side, oh-my-posh in Powershell is almost instantaneous.
|
Beta Was this translation helpful? Give feedback.
-
Code of Conduct
What happened?
I'm using git bash together with oh-my-posh, a simple 'echo hello' command taks 100ms to finish.
I've checked the script generated by oh-my-posh hook, the most expensive call is the one in _omp_start_timer():
oh-my-posh.exe get millis
It takes almost 50~80ms to finish, and to get the $omp_elapsed value, the script need to execute it twice.
The total time will be 100ms+other cost.
A possible solution could be use date and cut in the shell script to get the time.
The Windows Virus Protection is disabled while testing. This issue only happened in git-bash. Powershell works totally fine. I guess the powershell hook does not use this method to get the elapsed time.
A demo for this timer in powershell:
A demo of how slow it can be in bash:
Theme
I think this is not related to theme, the same theme works fine in Powershell.
Any theme can reproduce this issue, I tested it on this simple theme.
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"foreground": "#0CA0D8",
"style": "plain",
"template": "",
"type": "path"
}
],
"type": "prompt"
}
],
"version": 2
}
What OS are you seeing the problem on?
Windows
Which shell are you using?
bash
Log output
Beta Was this translation helpful? Give feedback.
All reactions