Closed SFM61319 closed 1 year ago
This is an issue because automated/UI tasks on editors like Visual Studio Code write commands to the terminal immediately after spawning it. This leads to the commands simply being read and discarded instead of being executed (because of Oh My Posh). Not using Oh My Posh (by removing eval "$(oh-my-posh init bash --config /mnt/c/Users/Svass/AppData/Local/Programs/oh-my-posh/themes/sigma.omp.json)"
from the ~/.bashrc
file) fixes this problem, but that defeats the whole purpose of using Oh My Posh.
Unrelated question: Are there plans to migrate to Rust anytime in the future?
@SFM61319 how can I reproduce this? All oh-my-posh does is overwrite the prompt, nothing else. So if they decide to hook into something, expecting certain preconditions (they do the exact same thing with their shell integration scripts), that can lead to unwanted side effects.
Are there plans to migrate to Rust anytime in the future?
Not at all, there's no benefit in doing that.
@SFM61319 how can I reproduce this? All oh-my-posh does is overwrite the prompt, nothing else. So if they decide to hook into something, expecting certain preconditions (they do the exact same thing with their shell integration scripts), that can lead to unwanted side effects.
One way to reproduce this is entering a command as soon as you launch a new terminal instance, before the first prompt is printed. If you missed it, you can also delay the next prompt (sleep <seconds>
) and enter a command before the next prompt is printed. You can try these with Oh My Posh first enabled, then disabled.
Are there plans to migrate to Rust anytime in the future?
Not at all, there's no benefit in doing that.
Ah, cool.
OhMyPosh_Enabled_Compressed.mp4 OhMyPosh_Disabled_Compressed.mp4
@JanDeDobbeleer (in case you weren't notified of my replies earlier, apologies for the mention).
@SFM61319 I saw them. Just didn't have time to check just yet. I'm working on another issue ATM as this isn't a critical bug per se.
@SFM61319 I can't reproduce this in bash 5.2.15 on my end. Are you on the latest bash?
@SFM61319 I can't reproduce this in bash 5.2.15 on my end. Are you on the latest bash?
@JanDeDobbeleer I'm using GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
on Ubuntu (WSL2).
@SFM61319 can you upgrade to the latest and try again? That version is a few years old already.
@JanDeDobbeleer I have just upgraded my Ubuntu WSL2 installation to 23.04. Also upgraded all my packages (including bash
) to the latest lunar
updates. WSL2 itself is already up-to-date.
My current bash
version is GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu)
, and I am still encountering the same problem. Are you sure you tried Oh My Posh using the config I provided?
@SFM61319 guilty as charged. I used my own config. Will try again.
@JanDeDobbeleer I have reencountered the issue. I am on the latest version of OhMyPosh (v18.6.0
), the newest version of Bash and Ubuntu on WSL2, and have the latest versions of all (direct and indirect) dependencies. I request you to reopen this issue.
@SFM61319 nothing changed in this implementation since this fix.
@SFM61319 nothing changed in this implementation since this fix.
I didn't test the fix on my side after updating OhMyPosh (because I simply trusted the fixed release). But today when I tried to debug a C++ program on Visual Studio Code, it didn't run because VS Code was writing the debug command to the terminal before the first OhMyPosh prompt got printed (which was the same issue as before).
@SFM61319 but did you add the correct setting to your configuration?
@SFM61319 but did you add the correct setting to your configuration?
@JanDeDobbeleer I haven't changed my configuration, it's exactly the same as the one I sent previously to reproduce the bug. What do you mean by the correct configuration?
@JanDeDobbeleer Nevermind, adding "disable_cursor_positioning": true
to the configuration fixed it. That was really silly of me. Anyway, thank you for taking the time to reply.
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.
Code of Conduct
What happened?
The terminal is not executing commands entered before the prompt is printed when Oh My Posh is used. When not using Oh My Posh, the terminal executes commands entered before a prompt is printed, producing expected behavior.
Actual behavior
Expected behavior
Theme
Custom theme:
JSON
```json { "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", "version": 2, "final_space": true, "terminal_background": "transparent", "blocks": [ { "type": "prompt", "alignment": "left", "segments": [ { "type": "os", "style": "diamond", "foreground": "p:white", "background": "p:black", "leading_diamond": "", "trailing_diamond": "", "properties": { "ubuntu": "What OS are you seeing the problem on?
Windows, Linux
Which shell are you using?
bash
Log output
Logs
```Shell Version: 17.5.2 Shell: bash (5.1.16(1)-release) Segments: ConsoleTitle(false) - 0 ms - os(true) - 0 ms - WSL at shell(true) - 0 ms - bash sysinfo(true) - 0 ms - CPU: 34.84% | RAM: 4/8GB executiontime(true) - 1 ms - 00:00:00.0 time(true) - 0 ms - Thursday, 2023-07-20 02:49:53.329 session(true) - 0 ms - sfm61319@Spidey path(true) - 0 ms - ~ git(false) - 0 ms - text(true) - 0 ms - $ Run duration: 12.512528ms Cache path: /home/sfm61319/.cache/oh-my-posh Config path: /mnt/c/Users/Svass/AppData/Local/Programs/oh-my-posh/themes/sigma.omp.json Logs: [DEBUG] 02:49:53.319 shell.go:Getenv:398 → NO DATA [TRACE] 02:49:53.319 shell.go:Getenv(TERM_PROGRAM) - 17.202µs [DEBUG] 02:49:53.319 shell.go:Getenv:398 → NO DATA [TRACE] 02:49:53.319 shell.go:Getenv(XDG_CACHE_HOME) - 2.385µs [TRACE] 02:49:53.319 shell_unix.go:CachePath() - 12.414µs [DEBUG] 02:49:53.319 shell.go:Getenv:398 → /mnt/c/Users/Svass/AppData/Local/Programs/oh-my-posh/themes/sigma.omp.json [TRACE] 02:49:53.319 shell.go:Getenv(POSH_THEME) - 4.258µs [DEBUG] 02:49:53.319 shell_unix.go:Platform:71 → ubuntu [TRACE] 02:49:53.319 shell.go:resolveConfigPath() - 13.215µs [TRACE] 02:49:53.319 shell.go:Init() - 178.198µs [TRACE] 02:49:53.319 shell.go:Flags() - 40ns [TRACE] 02:49:53.325 config.go:loadConfig() - 6.625691ms [TRACE] 02:49:53.325 shell.go:Flags() - 120ns [DEBUG] 02:49:53.325 shell.go:Getenv:398 → NO DATA [TRACE] 02:49:53.325 shell.go:Getenv(OMP_CACHE_DISABLED) - 5.14µs [TRACE] 02:49:53.326 shell_unix.go:Root() - 672ns [DEBUG] 02:49:53.326 shell.go:Shell:645 → process name: bash [TRACE] 02:49:53.326 shell.go:Shell() - 465.925µs [TRACE] 02:49:53.326 shell.go:ErrorCode() - 100ns [DEBUG] 02:49:53.326 shell_unix.go:IsWsl:35 → true [TRACE] 02:49:53.326 shell_unix.go:IsWsl() - 3.657µs [TRACE] 02:49:53.326 shell.go:GOOS() - 60ns [DEBUG] 02:49:53.326 shell.go:Pwd:428 → /home/sfm61319 [TRACE] 02:49:53.326 shell.go:Pwd() - 10.249µs [TRACE] 02:49:53.326 shell.go:GOOS() - 30ns [TRACE] 02:49:53.326 shell.go:GOOS() - 20ns [TRACE] 02:49:53.326 shell.go:GOOS() - 30ns [TRACE] 02:49:53.326 shell.go:GOOS() - 20ns [TRACE] 02:49:53.326 shell.go:GOOS() - 20ns [TRACE] 02:49:53.326 shell.go:GOOS() - 30ns [TRACE] 02:49:53.326 shell.go:GOOS() - 20ns [TRACE] 02:49:53.326 shell.go:GOOS() - 21ns [TRACE] 02:49:53.326 shell.go:GOOS() - 30ns [TRACE] 02:49:53.326 shell.go:GOOS() - 50ns [DEBUG] 02:49:53.326 shell.go:User:549 → sfm61319 [TRACE] 02:49:53.326 shell.go:User() - 6.883µs [DEBUG] 02:49:53.326 shell.go:Host:561 → Spidey [TRACE] 02:49:53.326 shell.go:Host() - 3.346µs [TRACE] 02:49:53.326 shell.go:GOOS() - 30ns [DEBUG] 02:49:53.326 shell_unix.go:Platform:71 → ubuntu [DEBUG] 02:49:53.326 shell.go:Getenv:398 → 1 [TRACE] 02:49:53.326 shell.go:Getenv(SHLVL) - 2.084µs [TRACE] 02:49:53.326 shell.go:TemplateCache() - 553.641µs [TRACE] 02:49:53.326 shell.go:Shell() - 60ns [DEBUG] 02:49:53.326 shell.go:Getenv:398 → 5.1.16(1)-release [TRACE] 02:49:53.326 shell.go:Getenv(POSH_SHELL_VERSION) - 2.444µs [DEBUG] 02:49:53.326 debug.go:PrintDebug:23 → Segment: Title [TRACE] 02:49:53.326 shell.go:Flags() - 30ns [DEBUG] 02:49:53.326 block.go:Debug:280 → Segment: os [TRACE] 02:49:53.326 shell.go:Pwd() - 60ns [TRACE] 02:49:53.326 shell.go:GOOS() - 30ns [TRACE] 02:49:53.326 shell.go:GOOS() - 30ns [DEBUG] 02:49:53.326 shell_unix.go:Platform:71 → ubuntu [DEBUG] 02:49:53.326 properties.go:GetBool:22 → display_distro_name: false [DEBUG] 02:49:53.326 properties.go:GetString:28 →