Skip to content

OSC 133 click_events support#1020

Merged
fdncred merged 7 commits intonushell:mainfrom
stuartcarnie:mouse-click-to-cursor
Feb 5, 2026
Merged

OSC 133 click_events support#1020
fdncred merged 7 commits intonushell:mainfrom
stuartcarnie:mouse-click-to-cursor

Conversation

@stuartcarnie
Copy link
Contributor

This PR builds on #1019 to add support for OSC 133 click_events=1. It is in draft for @fdncred to evaluate

@stuartcarnie stuartcarnie force-pushed the mouse-click-to-cursor branch 2 times, most recently from 70884ab to 3290851 Compare February 4, 2026 02:58
@fdncred
Copy link
Contributor

fdncred commented Feb 4, 2026

I've updated my PR so you may want to rebase again, or just wait until it's landed. Mitchell gave some advice that I decided to take with regards to 133;A vs 133;P, which is basically to always use 133;P.

@stuartcarnie stuartcarnie force-pushed the mouse-click-to-cursor branch from 3290851 to bd22df0 Compare February 4, 2026 23:11
@stuartcarnie
Copy link
Contributor Author

@fdncred I updated my branch too – using Nushell with all the goodies now!

@fdncred
Copy link
Contributor

fdncred commented Feb 5, 2026

@stuartcarnie is there a difference in the cl versus the click_events? mitchellh is saying here that we may get cl for free with osc133 #1019 (comment)

@fdncred
Copy link
Contributor

fdncred commented Feb 5, 2026

I landed #1019. when you have time it would be great to rebase

@mitchellh
Copy link

@stuartcarnie is there a difference in the cl versus the click_events? mitchellh is saying here that we may get cl for free with osc133 #1019 (comment)

click_events is significantly better if the shell can support it. It basically delegates all cursor movement to the shell (which is the source of truth that actually REALLY knows how all the navigation should work on the prompt line). It's just more work to implement than cl, which you're already getting for free with the recent OSC133 changes. If you can support click_events too that'd be ace!

Ghostty supports click_events along with Kitty, so probably should use both of those to verify this work. Thank you so much!

@stuartcarnie
Copy link
Contributor Author

@mitchellh / @fdncred yup, I implemented support for click_events and have been using it in Nushell + Ghostty for the past week – works great!

@fdncred
Copy link
Contributor

fdncred commented Feb 5, 2026

yay! I'll land this PR once it's green again and i have another quick trip through the code. Thanks @stuartcarnie!!

@stuartcarnie stuartcarnie force-pushed the mouse-click-to-cursor branch from bd22df0 to b168c40 Compare February 5, 2026 21:11
@stuartcarnie stuartcarnie marked this pull request as ready for review February 5, 2026 21:12
@stuartcarnie
Copy link
Contributor Author

@fdncred done!

Copy link
Contributor

@fdncred fdncred left a comment

Choose a reason for hiding this comment

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

Just some minor tweaks. Let me know if you think this is wrong. See this for reference.

//! Thanks to mitchellh for this tidbit, "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." So, with that in mind, we'll use `P`
//! for right prompts and left prompts.

Copy link
Contributor

@fdncred fdncred left a comment

Choose a reason for hiding this comment

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

Wow, this is a cool PR! Other than the comments I already made I'd just like to say thanks for doing such a good job. Looking forward to landing this.

I wish I could find a terminal on Windows that worked. I've tried Windows Terminal, Alacritty, WezTerm and don't see this working. I assume those terminals just don't support click_events.

@stuartcarnie
Copy link
Contributor Author

I wish I could find a terminal on Windows that worked. I've tried Windows Terminal, Alacritty, WezTerm and don't see this working. I assume those terminals just don't support click_events.

According to Mitchell, only Kitty and now Ghostty support click_events

I'll make the other changes shortly

@fdncred
Copy link
Contributor

fdncred commented Feb 5, 2026

Just so you know my plan, this is it.

  1. Land add native semantic prompt support initially for OSC 133/633 #1019 (done)
  2. Land OSC 133 click_events support #1020
  3. Land Add OSC 133 P (k=) markers for semantic prompts nushell#17468
  4. Land feat: enable OSC133 click events via reedline nushell#17491
  5. TBD - move other OSC escapes from nushell over to reedline (help wanted if you're interested)
  6. TBD - are there other escapes that ghostty supports that we could/should add? if so, let's do it.

I'd like to land these in order as soon as we can. No rush, just sharing.

@stuartcarnie
Copy link
Contributor Author

@fdncred I'm going to push the changes shortly – also added a couple of minor optimisations

Copy link
Contributor

@fdncred fdncred left a comment

Choose a reason for hiding this comment

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

Let's go!

@fdncred fdncred merged commit 9955d10 into nushell:main Feb 5, 2026
6 checks passed
@stuartcarnie
Copy link
Contributor Author

@fdncred it's ready – I'd like to refactor layout logic into a separate structure in a future PR, so that painting and snapshotting use the same logic

@fdncred
Copy link
Contributor

fdncred commented Feb 5, 2026

@fdncred it's ready – I'd like to refactor layout logic into a separate structure in a future PR, so that painting and snapshotting use the same logic

Sure. Ping me when you have something and I'll look it over!

@stuartcarnie stuartcarnie deleted the mouse-click-to-cursor branch February 5, 2026 22:46
fdncred pushed a commit to nushell/nushell that referenced this pull request Feb 6, 2026
<!--
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>
TestingPlant pushed a commit to TestingPlant/nushell that referenced this pull request Feb 6, 2026
<!--
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>
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.

3 participants