JanDeDobbeleer / oh-my-posh

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

Two-line transient prompt cuts of last line from previous command #4694

Closed FlorianLoch closed 8 months ago

FlorianLoch commented 8 months ago

Code of Conduct

What happened?

I am not quite sure this is an actual bug, it might also be related to my config - but I compared it to the documentation and did not spot an (obvious) issue.

I attached a video that show the problem: the transient prompt feature seems to not only remove the lines itself occupied, but also the line above this. So it cuts off the last line of the previous command's output.

https://github.com/JanDeDobbeleer/oh-my-posh/assets/5587805/8fe37d13-9a57-471d-9b16-26c340c6596a

Theme

# yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
final_space: true
version: 2
blocks:
  # Add a blank line for separation
  - alignment: left
    type: prompt
    segments:
      - type: text
        style: plain
  - alignment: left
    newline: false
    type: prompt
    segments:
      - type: "path"
        background: "#c386f1"
        foreground: "#2b2b2b"
        leading_diamond: "\ue0b6"
        style: "diamond"
        trailing_diamond: "\ue0b0"
        template: "  {{ .Path }} "
      - type: git
        background: "#57ffc5"
        background_templates:
          - "{{ if or (.Working.Changed) (.Staging.Changed) }}#ffc157{{ end }}"
          - "{{ if and (gt .Ahead 0) (gt .Behind 0) }}#ff5775{{ end }}"
          - "{{ if gt .Ahead 0 }}#ff5775{{ end }}"
          - "{{ if gt .Behind 0 }}#ff5775{{ end }}"
        foreground: '#2b2b2b'
        properties:
          branch_max_length: 25
          fetch_stash_count: true
          fetch_status: true
          fetch_upstream_icon: true
        style: "powerline"
        powerline_symbol: "\ue0b0"
        template: " {{ .UpstreamIcon }}{{ .Ref }}{{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 }} "
      - type: executiontime
        background: 'yellow'
        foreground: 'black'
        # style: "powerline"
        style: "diamond"
        properties:
          style: austin
          threshold: 1000
        powerline_symbol: "\ue0b0"
        template: " {{ .FormattedMs }} "
        leading_diamond: " "
        trailing_diamond: " "
  - alignment: right
    type: prompt
    newline: false
    segments:
      - background: '#29315A'
        foreground: '#E4F34A'
        leading_diamond: ' '
        properties:
          fetch_version: false
        style: diamond
        template: >-
           {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{
          end }}{{ .Full }}{{ end }}
        trailing_diamond: 
        type: python
      - type: go
        background: '#29315A'
        foreground: '#7FD5EA'
        leading_diamond: ' '
        properties:
          fetch_version: true
          parse_mod_file: true
        style: diamond
        template: "\u202D\uFCD1 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}"
        trailing_diamond: 
      - type: kubectl
        background: 'blue'
        foreground: 'white'
        leading_diamond: ' '
        properties:
          fetch_version: true
          parse_mod_file: true
        style: diamond
        # Do not need the cluster to be shown - but would be: {{ .Cluster }}
        template: "\uFD31 {{ if .Namespace }}{{ .Namespace }}{{ else }}default{{ end }}"
        trailing_diamond: " "
      - type: node
        background: '#29315A'
        foreground: '#42E66C'
        leading_diamond: ' '
        properties:
          fetch_version: false
        style: diamond
        template: >-
          {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{
          .Full }}
        trailing_diamond: 
      - background: '#29315A'
        foreground: '#E64747'
        leading_diamond: ' '
        properties:
          fetch_version: false
        style: diamond
        template: {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}
        trailing_diamond: 
        type: ruby
      - background: '#29315A'
        foreground: '#E64747'
        leading_diamond: ' '
        properties:
          fetch_version: false
        style: diamond
        template: {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}
        trailing_diamond: 
        type: java
      - background: '#29315A'
        foreground: '#9B6BDF'
        leading_diamond: ' '
        properties:
          fetch_version: false
        style: diamond
        template: '{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} '
        trailing_diamond: 
        type: julia
      - type: php
        style: diamond
        foreground: '#ffffff'
        background: '#4063D8'
        leading_diamond: ' '
        properties:
          fetch_version: false
        template: ' {{ .Full }} '
        trailing_diamond: 
  - alignment: left
    type: prompt
    newline: true
    segments:
      - type: text
        # background: '#29315A'
        foreground_templates:
          - "{{ if ne .Code 0 }}#e24846{{ else }}#46e27f{{ end }}"
        # leading_diamond: 
        style: diamond
        template: '❯'
        # trailing_diamond: 
transient_prompt:
  # type: "text"
  foreground: "#bba4db"
  template: '{{ now | date "15:04:05" }} ❯ '

What OS are you seeing the problem on?

macOS

Which shell are you using?

zsh 5.9

Log output

Can provide this if required, but need to strip some sensitive data first :/
JanDeDobbeleer commented 8 months ago

@FlorianLoch which shell is this? PowerShell has a bug that does this. We set the prompt lines correctly, but on redraw they don't respect this somehow.

FlorianLoch commented 8 months ago

Oh, sorry for omitting this... It's zsh 5.9 running inside iterm2. I will update the template above too.

JanDeDobbeleer commented 8 months ago

@FlorianLoch cool, I'll have a look at how to reproduce that there as well.

JanDeDobbeleer commented 8 months ago

@FlorianLoch I can't reproduce this at all.

image

Something else on your zsh setup/machine is influencing this negatively.