oh-my-fish / theme-bobthefish

A Powerline-style, Git-aware fish theme optimized for awesome.
MIT License
1.46k stars 227 forks source link

Slow prompt on WSL 2 #285

Closed Holt59 closed 3 years ago

Holt59 commented 3 years ago

I'm using the theme on WSL2 and the prompt takes a few hundreds of milliseconds to show after a command. I found a few issues there and there talking about git or PATHs, but nothing solved it.

The default theme (which has some git features) does not show this behavior. Is there anyway I can "debug" this?

bobthecow commented 3 years ago

The main prompt function is split up into a bunch of calls for individual segments. If you edit it and comment them all out, you can add 'em back in one at a time and see which one(s) make it slow.

Holt59 commented 3 years ago

Thanks! It was actually the _rubies call, and it turned out that was because I did not remove Windows PATH properly (forgot to shutdown WSL).

jjh2811 commented 2 months ago

I came across here while trying to find a solution to the same problem. It seemed like the original poster got a hint and solved it on his own, but the fragmented information provided didn’t help me at all. So, I decided to dig into it myself and eventually found a solution. I’m leaving a more detailed explanation here for anyone who might end up here like I did, looking for answers.

First, I haven’t been using WSL for long, but I experienced this issue initially. Although it was annoying, I just adapted to it by pressing Enter a little less often so I wouldn't feel irritated. One day, I got frustrated enough to look into it. The developer here suggested editing the main prompt function (at the time, I didn’t even know where the local repository of the bobthefish script was). After some digging, I found the function and tried a few modifications. I noticed that a lot of time was consumed by a function that checks the Ruby environment. Upon further inspection, I realized it was the 'command' in the fish shell itself that was causing the delay.

So, I headed over to the fish shell GitHub and searched through the issues, where I found a mention of the PATH variable. That’s when something clicked for me. I ran echo $PATH in the command line, and it was extremely long. This is when I realized that WSL includes the Windows PATH by default. No wonder Windows commands work even in the WSL environment.

Anyway, after some further searching, I found that to exclude the Windows PATH, you need to add the following to /etc/wsl.conf: [interop] appendWindowsPath=false

After making this change and restarting WSL, and BAAM, the problem was completely solved.

TL;DR If your prompt is slow in WSL, open /etc/wsl.conf as root and add the following:

[interop]
appendWindowsPath=false

and restart WSL