Skip to content

Feat/zsh transient multiline#7360

Open
kovjanos wants to merge 1 commit intoJanDeDobbeleer:mainfrom
kovjanos:feat/zsh-transient-multiline
Open

Feat/zsh transient multiline#7360
kovjanos wants to merge 1 commit intoJanDeDobbeleer:mainfrom
kovjanos:feat/zsh-transient-multiline

Conversation

@kovjanos
Copy link
Copy Markdown

@kovjanos kovjanos commented Mar 3, 2026

Prerequisites

  • I have read and understood the contributing guide.
  • The commit message follows the conventional commits guidelines.
  • Tests for the changes have been added (for bug fixes / features).
  • Docs have been added/updated (for bug fixes / features).

Description

Previously while multiline command was typed the prompt changed to transient_prompt. If a multiline prompt was used with e.g. a single line transient_prompt, that caused the prompt replaced with transient prompt right after the first enter was hit after "\" in the multiline command.
With the changes the multiline prompt is kept until the multiline command is submitted.

  1. Code Change: Implemented multi-line command support for Zsh transient prompts in src/shell/scripts/omp.zsh.
  2. Conventional Commits: Verified and committed with the following messages:
    • feat(zsh): support transient prompt for multi-line commands
    • docs: update transient prompt documentation for Zsh multi-line support
  3. Tests: Ran go test ./... in the src directory, and all 23 tests passed. Manual verification confirmed the fix works for both
    multi-line entry and Ctrl-C interrupts.
  4. Documentation: Added a tip to website/docs/configuration/transient.mdx regarding the improved Zsh multi-line support.

@kovjanos kovjanos force-pushed the feat/zsh-transient-multiline branch from ea0e341 to b3e9f63 Compare March 3, 2026 17:18

# set secondary prompt
_omp_secondary_prompt=$($_omp_executable print secondary --shell=zsh)
_omp_secondary_prompt_plain=$($_omp_executable print secondary --shell=zsh --plain --escape=false)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was needed to avoid ZHS markers that couldn't be re-encoded to mess up the secondary_prompt by directly injecting into the buffer. Made a change to be able to keep original behavior by default - see new changes.

@kovjanos kovjanos force-pushed the feat/zsh-transient-multiline branch from b3e9f63 to 1d5d9a6 Compare March 4, 2026 07:46
@kovjanos
Copy link
Copy Markdown
Author

kovjanos commented Mar 4, 2026

@JanDeDobbeleer The _omp_secondary_prompt_plain is used to re-inject prompt content w/o the zsh markers. It unfortunately sinks some control sequences (like coloring) but I didn't find an easy way to re-encode them.
This would of course affect the secondary_prompt behavior so I extended it (actually rearranged/changed the logic) and put it behind a config flag for those who prefer the look of the secondary_prompt over keeping the prompt against transient_prompt for multi-line commands.

@kovjanos kovjanos force-pushed the feat/zsh-transient-multiline branch from 1d5d9a6 to 5dae27b Compare March 6, 2026 22:33
@kovjanos kovjanos force-pushed the feat/zsh-transient-multiline branch from 5dae27b to 25ce68b Compare March 6, 2026 22:37
@kovjanos
Copy link
Copy Markdown
Author

kovjanos commented Mar 6, 2026

fyi: rebased the changes and also providing the details about the behavioral change:

Imagine you have:

  • transient_prompt with a single line with time prefix

  • prompt is multiline: one separator line, one info line with e.g. time, user, host, path and the 3rd line is the actual imput prompt

  • seondary prompt is only spaces to ident input

Current behaviour is that if you have some old propts with transient_prompt and the actual input:

 [23:48:43]❯ return 0

  23:48:43 - jkovacs@macbook:~/ 
❯ curl \

and you hit an enter after "\", your prompt is immediately replaced with the transient prompt, e.g.:

[23:48:43]❯ return 0
[23:51:46]❯ curl \
  -k

With the new property set to true, e.g.:

[secondary_prompt]
  multiline_keepprompt = true
  template = "  "

the behavior will change. e.g. from the same initial state:

[23:48:43]❯ return 0

  23:48:43 - jkovacs@macbook:~/ 
❯ curl \

if you hit enter, the prompt will not change to transient_prompt:

[23:54:57]❯ return 0

  23:54:57 - jkovacs@macbook:~/ 
❯ curl \
  -k \
  http://localhost/nice

only if you submit the command:

[23:54:57]❯ return 0
[23:57:31]❯ curl \
  -k \
  http://localhost/nice
Hello, World!

  23:57:31 - jkovacs@macbook:~/ 
❯

@kovjanos kovjanos mentioned this pull request Mar 6, 2026
4 tasks
@kovjanos
Copy link
Copy Markdown
Author

@JanDeDobbeleer could you please have another look on the change?
There is also another one - #7369 - on top of this to further enhance prompt behavior.

@JanDeDobbeleer
Copy link
Copy Markdown
Owner

@kovjanos I've been crazy busy but I'll get to it latest next week!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants