add native semantic prompt support initially for OSC 133/633#1019
add native semantic prompt support initially for OSC 133/633#1019fdncred merged 4 commits intonushell:mainfrom
Conversation
| //! - `B` - Marks the end of prompt and start of user input | ||
| //! - `C` - Marks the start of command execution (emitted by shell, not reedline) | ||
| //! - `D` - Marks the end of command execution with exit code (emitted by shell) | ||
| //! - `P` - Sets a property (used for right prompt marker `k=r`) |
There was a problem hiding this comment.
This is technically P for prompt. So it starts a prompt. The A is kind of weird: it does a \r\n if the cursor isn't at x=0 and THEN does a P. If you want, you can use P all the time instead of A for example if you're not sure if the cursor will be at x=0 😄
There was a problem hiding this comment.
ok, I've updated the comments with your suggestion and the code, of course. I left the vscode at 633;A but change the others to 133;P all the time. Thanks for the tip.
|
This looks great! You may want to consider extending this to support an optional I don't know the full reedline/downstream relationship so I'm not sure if that can be safely defaulted to any value or if downstream must always opt-in. I think with proper OSC133 support, Nushell should be able to support |
Someone is already trying to implement click_events based off my reedline PR that hasn't landed yet. https://github.com/nushell/reedline/pull/1020/changes#diff-abcd983172046f9e9f64a31934996ed8bb05d631180ededb428e319e37753997R105 |
|
let's move forward with this for now. hopefully will land click_events=1 pr next #1020 |
<!-- Thank you for improving Nushell! Please, read our contributing guide: https://github.com/nushell/nushell/blob/main/CONTRIBUTING.md --> ## Summary - Enable OSC 133 semantic prompt markers (via @fdncred / nushell/reedline/pull/1019) - Enable OSC 133 click_events (via nushell/reedline/pull/1020). - Keep OSC 633 support for VS Code and prefer it when available. ## Testing - `cargo test -p nu-cli prompt_does_not_embed_osc_markers` - `cargo test -p nu-cli semantic_markers_` - `cargo test -p nu-protocol click_to_cursor_is_unknown_option` ## Release notes summary - What our users need to know - Enabling `shell_integration.osc133` now also enables click-to-cursor in supported terminals. ## Tasks after submitting - [ ] Update the [documentation](https://github.com/nushell/nushell.github.io) <details> <summary<strong>DEMO</strong></summary> https://github.com/user-attachments/assets/ce11079f-0c4f-4f90-a1b1-e3c3d0b99351 </details>
<!-- Thank you for improving Nushell! Please, read our contributing guide: https://github.com/nushell/nushell/blob/main/CONTRIBUTING.md --> ## Summary - Enable OSC 133 semantic prompt markers (via @fdncred / nushell/reedline/pull/1019) - Enable OSC 133 click_events (via nushell/reedline/pull/1020). - Keep OSC 633 support for VS Code and prefer it when available. ## Testing - `cargo test -p nu-cli prompt_does_not_embed_osc_markers` - `cargo test -p nu-cli semantic_markers_` - `cargo test -p nu-protocol click_to_cursor_is_unknown_option` ## Release notes summary - What our users need to know - Enabling `shell_integration.osc133` now also enables click-to-cursor in supported terminals. ## Tasks after submitting - [ ] Update the [documentation](https://github.com/nushell/nushell.github.io) <details> <summary<strong>DEMO</strong></summary> https://github.com/user-attachments/assets/ce11079f-0c4f-4f90-a1b1-e3c3d0b99351 </details>
This PR adds native support for semantic prompt markers (OSC 133/633) to reedline, enabling proper terminal integration with Ghostty, VS Code, and other terminals that support the FinalTerm semantic prompts specification.
\x1b\\) terminator, not BEL (\x07)with_semantic_markers()There are 2 new examples.
semantic_prompt_verifyis for manually inspecting the output to see what it looks like to humans.semantic_prompt_interactiveis for using with ghostty or similar tools that provide a debug interface to see the escapes. for ghostty, use the "Terminal Inspector" and then on the Renderer menu make sure you enable Overlay Semantic Prompts.I've done my best to ensure that these escapes are per spec. Let me know if you disagree or think I've missed something.
Example semantic_prompt_verify
Example semantic_prompt_interactive