Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow full prompt config for transient prompt #5782

Open
1 task done
kritag opened this issue Oct 27, 2024 · 4 comments
Open
1 task done

feat: allow full prompt config for transient prompt #5782

kritag opened this issue Oct 27, 2024 · 4 comments
Assignees
Labels
🤩 enhancement Improvement of a feature

Comments

@kritag
Copy link

kritag commented Oct 27, 2024

Code of Conduct

  • I agree to follow this project's Code of Conduct

What would you like to see changed?

Currently I have my prompt set up like this:
image

This works fine for the most part except when windows are resized and spawn with a different size, as is the case often with tiling window managers.

In my config I have set the right-hand prompt to be a regular prompt with alignment: right and this enables me to have the CWD as seen on the left on the same line as kubernetes and other information on the right.

I would like to switch to rprompt for the right-hand side, as this removes the issue about the prompt moving around like this:
image

How can you have transient prompt like in the first image, but have the rprompt be on the same line as the cwd-part? if I change the right-hand part to rprompt it is on the same line as the prompt itself no matter what I try to do with newlines etc:
image

Here is my config for reference:

$schema: "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json"
final_space: true
disable_notice: true
auto_upgrade: false
version: 2
blocks:
  - alignment: left
    type: prompt
    segments:
      - type: path
        background: magenta
        foreground: black
        trailing_diamond: 
        leading_diamond: 
        style: diamond
        #template: "{{ if .Writable }}{{else}}{{end}}<b>{{ .Path }}</b>"
        template: "<b>{{ .Path }}</b>"
        properties:
          style: full
          folder_format: "%s"
      - type: git
        background_templates:
          - "{{ if or (.Working.Changed) (.Staging.Changed) }}lightYellow{{ end }}"
          - "{{ if and (gt .Ahead 0) (gt .Behind 0) }}red{{ end }}"
          - "{{ if gt .Ahead 0 }}blue{{ end }}"
          - "{{ if gt .Behind 0 }}lightRed{{ end }}"
        foreground_templates:
          - "{{ if or (.Working.Changed) (.Staging.Changed) }}black{{ end }}"
          - "{{ if and (gt .Ahead 0) (gt .Behind 0) }}black{{ end }}"
          - "{{ if gt .Ahead 0 }}black{{ end }}"
        background: green
        foreground: black
        style: powerline
        powerline_symbol: 
        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: ""
          cherry_pick_icon: ""
          commit_icon: ""
          fetch_status: true
          fetch_upstream_icon: false
          merge_icon: ""
          no_commits_icon: ""
          rebase_icon: ""
          revert_icon: ""
          tag_icon: ""
  - type: session
    style: diamond
    leading_diamond: 
    trailing_diamond: 
    template: " {{ if .SSHSession }}{{ end }}{{ .UserName }} "
    background: lightCyan
    foreground: black
  - type: prompt
    alignment: right
    # newline: true
    segments:
      - type: kubectl
        background: lightBlue
        foreground: black
        leading_diamond: 
        trailing_diamond: 
        style: diamond
        template: '{{ $context := splitList "/" .Context }}{{ index $context 0 }}'
      - type: kubectl
        background: cyan
        foreground: black
        leading_diamond: 
        trailing_diamond: 
        style: diamond
        template: '<b>{{ $context := splitList "/" .Context }} {{$cluster:=regexReplaceAll "^api-os-" .Cluster "" }}{{ $leftMost := regexReplaceAll "-[^-]+-[^-]+:.*" $cluster "" }}{{ $leftMost }} </b>'
      - type: kubectl
        background: yellow
        foreground: black
        leading_diamond: 
        style: diamond
        template: "{{ .Namespace }}"
        trailing_diamond: 
  - type: prompt
    alignment: left
    newline: true
    segments:
      - background: transparent
        foreground_templates:
          - "{{if gt .Code 0}}red{{end}}"
          - "{{if eq .Code 0}}lightBlue{{end}}"
        style: plain
        template: 
        type: text
transient_prompt:
  foreground_templates:
    - "{{if gt .Code 0}}red{{end}}"
    - "{{if eq .Code 0}}green{{end}}"
  background: transparent
  template: ""
secondary_prompt:
  foreground: lightBlue
  background: transparent
  template: "❯❯ "
@kritag kritag added the 🤩 enhancement Improvement of a feature label Oct 27, 2024
@JanDeDobbeleer
Copy link
Owner

@kritag you can't. The transient prompt is a simplified prompt so you can't enable a full prompt config. This might be something to explore, but today that's not an option.

@JanDeDobbeleer JanDeDobbeleer changed the title rprompt with transient prompt not on the same line feat: allow full prompt config for transient prompt Oct 28, 2024
@kritag
Copy link
Author

kritag commented Oct 28, 2024

Ah, bummer! Thanks for taking the time to reply anyhow :)

@kritag
Copy link
Author

kritag commented Oct 29, 2024

If i disable the transient prompt alltogether I still get the same behavior having rprompt on the same line of the prompt. Is there like a hack of sorts to push the rprompt one line above? I mean, here is the behavior with transient prompt disabled:
image
If I add a newline in the rprompt segment I get:
image
Does this mean that rprompt is always rendered last, no matter how you structure your configuration? Or is there a way to structure it in order to achieve the result I'm after?

@JanDeDobbeleer
Copy link
Owner

@kritag rprompt will always be rendered on the line of the cursor, that's the design (native, or not). If you want to display it above, create a right aligned prompt rather than an rprompt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤩 enhancement Improvement of a feature
Projects
None yet
Development

No branches or pull requests

2 participants