oh-my-posh: Terminal not executing commands entered before prompt is printed

Code of Conduct

  • I agree to follow this project’s 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 image image
Expected behavior image image

Theme

Custom theme:

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": "<p:theme></> ",
            "windows": "<p:theme></> "
          }
        },
        {
          "type": "shell",
          "style": "diamond",
          "foreground": "p:white",
          "background": "p:black",
          "leading_diamond": "",
          "trailing_diamond": ""
        },
        {
          "type": "sysinfo",
          "style": "diamond",
          "foreground": "p:white",
          "background": "p:black",
          "leading_diamond": "",
          "trailing_diamond": "",
          "template": "<p:theme></> CPU: {{ round .PhysicalPercentUsed .Precision }}% | RAM: {{ (div ((sub .PhysicalTotalMemory .PhysicalFreeMemory)|float64) 1000000000.0) }}/{{ (div .PhysicalTotalMemory 1000000000.0) }}GB <p:theme></> "
        }
      ],
      "newline": true
    },
    {
      "type": "prompt",
      "alignment": "right",
      "segments": [
        {
          "type": "executiontime",
          "style": "diamond",
          "foreground": "p:white",
          "background": "p:black",
          "leading_diamond": "",
          "trailing_diamond": "",
          "template": "<p:theme></> {{ .FormattedMs }} <p:theme></> ",
          "properties": {
            "style": "houston",
            "threshold": 0
          }
        },
        {
          "type": "time",
          "style": "diamond",
          "foreground": "p:white",
          "background": "p:black",
          "leading_diamond": "",
          "trailing_diamond": "",
          "properties": {
            "time_format": "<p:theme></> Monday, 2006-01-02 15:04:05.000 <p:theme></> "
          }
        }
      ]
    },
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "session",
          "style": "diamond",
          "foreground": "p:theme",
          "background": "p:black",
          "leading_diamond": "",
          "trailing_diamond": ""
        },
        {
          "type": "path",
          "style": "diamond",
          "foreground": "p:black",
          "background": "p:theme",
          "leading_diamond": "",
          "trailing_diamond": "",
          "properties": {
            "style": "full"
          }
        }
      ],
      "newline": true
    },
    {
      "type": "prompt",
      "alignment": "right",
      "segments": [
        {
          "type": "git",
          "style": "diamond",
          "foreground": "p:black",
          "background": "p:green",
          "leading_diamond": "",
          "trailing_diamond": "",
          "template": " {{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }}  {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }}  {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }}  {{ .StashCount }}{{ end }} ",
          "properties": {
            "branch_icon": " ",
            "fetch_stash_count": true,
            "fetch_status": true,
            "fetch_upstream_icon": true,
            "fetch_worktree_count": true
          }
        }
      ]
    },
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "text",
          "style": "plain",
          "template": "<p:theme>$</>"
        }
      ],
      "newline": true
    }
  ],
  "palettes": {
    "template": "{{ if .WSL }}ubuntu{{ else }}windows{{ end }}",
    "list": {
      "windows": {
        "black": "#000000",
        "blue": "#4CC2FF",
        "green": "#1DB954",
        "orange": "#F39456",
        "white": "#FFFFFF",
        "theme": "p:blue"
      },
      "ubuntu": {
        "black": "#000000",
        "blue": "#4CC2FF",
        "green": "#1DB954",
        "orange": "#F39456",
        "white": "#FFFFFF",
        "theme": "p:orange"
      }
    }
  }
}

What OS are you seeing the problem on?

Windows, Linux

Which shell are you using?

bash

Log output

Logs
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 → <p:theme></> 
[TRACE] 02:49:53.326 shell.go:TemplateCache() - 100ns
[TRACE] 02:49:53.326 shell.go:TemplateCache() - 211ns
[TRACE] 02:49:53.326 shell.go:Shell() - 151ns
[DEBUG] 02:49:53.327 block.go:Debug:280 → Segment: shell
[TRACE] 02:49:53.327 shell.go:Pwd() - 110ns
[TRACE] 02:49:53.327 shell.go:GOOS() - 40ns
[DEBUG] 02:49:53.327 properties.go:GetKeyValueMap:46 → mapped_shell_names: map[]
[TRACE] 02:49:53.327 shell.go:Shell() - 40ns
[TRACE] 02:49:53.327 shell.go:Flags() - 30ns
[TRACE] 02:49:53.327 shell.go:TemplateCache() - 100ns
[TRACE] 02:49:53.327 shell.go:TemplateCache() - 80ns
[TRACE] 02:49:53.327 shell.go:Shell() - 50ns
[DEBUG] 02:49:53.327 block.go:Debug:280 → Segment: sysinfo
[DEBUG] 02:49:53.327 properties.go:GetInt:40 → precision: 2
[TRACE] 02:49:53.327 shell.go:Pwd() - 100ns
[TRACE] 02:49:53.327 shell.go:GOOS() - 31ns
[TRACE] 02:49:53.327 shell.go:TemplateCache() - 50ns
[TRACE] 02:49:53.327 shell.go:TemplateCache() - 70ns
[TRACE] 02:49:53.327 shell.go:Shell() - 100ns
[TRACE] 02:49:53.327 shell.go:Flags() - 30ns
[DEBUG] 02:49:53.327 block.go:Debug:280 → Segment: executiontime
[TRACE] 02:49:53.327 shell.go:Pwd() - 70ns
[TRACE] 02:49:53.327 shell.go:GOOS() - 30ns
[DEBUG] 02:49:53.327 properties.go:GetBool:22 → always_enabled: false
[TRACE] 02:49:53.327 shell.go:ExecutionTime() - 40ns
[DEBUG] 02:49:53.327 properties.go:GetFloat64:34 → threshold: 0.000000
[DEBUG] 02:49:53.327 properties.go:GetString:28 → houston
[TRACE] 02:49:53.327 shell.go:TemplateCache() - 120ns
[TRACE] 02:49:53.329 shell.go:TemplateCache() - 321ns
[TRACE] 02:49:53.329 shell.go:Shell() - 100ns
[DEBUG] 02:49:53.329 block.go:Debug:280 → Segment: time
[TRACE] 02:49:53.329 shell.go:Pwd() - 80ns
[TRACE] 02:49:53.329 shell.go:GOOS() - 30ns
[DEBUG] 02:49:53.329 properties.go:GetString:28 → <p:theme></> Monday, 2006-01-02 15:04:05.000 <p:theme></> 
[TRACE] 02:49:53.329 shell.go:TemplateCache() - 100ns
[TRACE] 02:49:53.329 shell.go:TemplateCache() - 81ns
[TRACE] 02:49:53.329 shell.go:Shell() - 50ns
[TRACE] 02:49:53.329 shell.go:Flags() - 30ns
[DEBUG] 02:49:53.329 block.go:Debug:280 → Segment: session
[TRACE] 02:49:53.329 shell.go:Pwd() - 40ns
[TRACE] 02:49:53.329 shell.go:GOOS() - 40ns
[DEBUG] 02:49:53.329 shell.go:Getenv:398 → NO DATA
[TRACE] 02:49:53.329 shell.go:Getenv(SSH_CONNECTION) - 2.355µs
[DEBUG] 02:49:53.329 shell.go:Getenv:398 → NO DATA
[TRACE] 02:49:53.329 shell.go:Getenv(SSH_CLIENT) - 1.403µs
[TRACE] 02:49:53.329 shell.go:TemplateCache() - 60ns
[TRACE] 02:49:53.329 shell.go:TemplateCache() - 90ns
[TRACE] 02:49:53.329 shell.go:Shell() - 60ns
[DEBUG] 02:49:53.329 block.go:Debug:280 → Segment: path
[TRACE] 02:49:53.329 shell.go:Pwd() - 30ns
[TRACE] 02:49:53.329 shell.go:GOOS() - 30ns
[TRACE] 02:49:53.329 shell.go:Pwd() - 30ns
[TRACE] 02:49:53.329 shell.go:Shell() - 20ns
[TRACE] 02:49:53.329 shell.go:Shell() - 20ns
[DEBUG] 02:49:53.329 properties.go:GetBool:22 → mapped_locations_enabled: true
[DEBUG] 02:49:53.329 properties.go:GetString:28 → 
[DEBUG] 02:49:53.329 properties.go:GetString:28 → 
[TRACE] 02:49:53.329 shell.go:GOOS() - 20ns
[DEBUG] 02:49:53.329 properties.go:GetString:28 → ~
[DEBUG] 02:49:53.329 properties.go:GetKeyValueMap:46 → mapped_locations: map[]
[TRACE] 02:49:53.329 shell.go:PathSeparator() - 40ns
[TRACE] 02:49:53.329 shell.go:GOOS() - 30ns
[TRACE] 02:49:53.329 shell.go:GOOS() - 30ns
[TRACE] 02:49:53.329 shell.go:GOOS() - 30ns
[TRACE] 02:49:53.329 shell.go:GOOS() - 30ns
[TRACE] 02:49:53.329 shell.go:PathSeparator() - 20ns
[TRACE] 02:49:53.329 shell.go:PathSeparator() - 70ns
[TRACE] 02:49:53.329 shell.go:GOOS() - 30ns
[TRACE] 02:49:53.329 shell.go:GOOS() - 20ns
[TRACE] 02:49:53.329 shell.go:PathSeparator() - 30ns
[TRACE] 02:49:53.329 shell.go:GOOS() - 20ns
[TRACE] 02:49:53.329 shell.go:GOOS() - 30ns
[TRACE] 02:49:53.329 shell.go:PathSeparator() - 30ns
[TRACE] 02:49:53.329 shell.go:GOOS() - 20ns
[TRACE] 02:49:53.329 shell.go:GOOS() - 20ns
[TRACE] 02:49:53.329 shell.go:PathSeparator() - 20ns
[TRACE] 02:49:53.330 shell.go:Pwd() - 30ns
[DEBUG] 02:49:53.330 shell_unix.go:IsWsl:35 → true
[TRACE] 02:49:53.330 shell_unix.go:IsWsl() - 2.635µs
[DEBUG] 02:49:53.330 shell.go:RunCommand:579 → //wsl.localhost/Ubuntu/home/sfm61319
[TRACE] 02:49:53.330 shell.go:RunCommand(wslpath -m /home/sfm61319) - 663.79µs
[TRACE] 02:49:53.330 shell.go:StackCount() - 80ns
[TRACE] 02:49:53.330 shell_unix.go:DirIsWritable(/home/sfm61319) - 4.158µs
[TRACE] 02:49:53.330 shell.go:TemplateCache() - 171ns
[TRACE] 02:49:53.330 shell.go:TemplateCache() - 181ns
[TRACE] 02:49:53.330 shell.go:Shell() - 90ns
[TRACE] 02:49:53.330 shell.go:Flags() - 30ns
[DEBUG] 02:49:53.330 block.go:Debug:280 → Segment: git
[TRACE] 02:49:53.330 shell.go:Pwd() - 60ns
[TRACE] 02:49:53.330 shell.go:GOOS() - 40ns
[DEBUG] 02:49:53.330 shell_unix.go:IsWsl:35 → true
[TRACE] 02:49:53.330 shell_unix.go:IsWsl() - 2.044µs
[DEBUG] 02:49:53.330 shell.go:FileContent:523 ↓
    5.15.90.1-microsoft-standard-WSL2
    
[TRACE] 02:49:53.330 shell.go:FileContent(/proc/sys/kernel/osrelease) - 40.387µs
[TRACE] 02:49:53.330 shell_unix.go:IsWsl2() - 47.01µs
[TRACE] 02:49:53.330 shell.go:Pwd() - 60ns
[DEBUG] 02:49:53.331 shell.go:RunCommand:579 → //wsl.localhost/Ubuntu/home/sfm61319
[TRACE] 02:49:53.331 shell.go:RunCommand(wslpath -m /home/sfm61319) - 453.401µs
[TRACE] 02:49:53.331 shell.go:GOOS() - 50ns
[DEBUG] 02:49:53.331 shell.go:CommandPath:600 → /usr/bin/git
[TRACE] 02:49:53.331 shell.go:CommandPath(git) - 19.437µs
[TRACE] 02:49:53.331 shell.go:HasCommand(git) - 23.675µs
[TRACE] 02:49:53.331 shell.go:Pwd() - 100ns
[ERROR] 02:49:53.331 shell.go:HasParentFilePath:733 → stat .git: no such file or directory
[TRACE] 02:49:53.331 shell.go:HasParentFilePath(.git) - 17.393µs
[DEBUG] 02:49:53.331 properties.go:GetBool:22 → fetch_bare_info: false
[TRACE] 02:49:53.331 shell.go:Flags() - 40ns
[DEBUG] 02:49:53.331 block.go:Debug:280 → Segment: text
[TRACE] 02:49:53.331 shell.go:Pwd() - 40ns
[TRACE] 02:49:53.331 shell.go:GOOS() - 40ns
[TRACE] 02:49:53.331 shell.go:TemplateCache() - 120ns
[TRACE] 02:49:53.331 shell.go:Shell() - 101ns
[DEBUG] 02:49:53.331 shell.go:Getenv:398 → NO DATA
[TRACE] 02:49:53.331 shell.go:Getenv(XDG_CACHE_HOME) - 2.805µs
[TRACE] 02:49:53.331 shell_unix.go:CachePath() - 10.651µs
[TRACE] 02:49:53.331 shell.go:Flags() - 40ns

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@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.

@SFM61319 guilty as charged. I used my own config. Will try again.

@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.