Terminal: How to move cursor using mouse

Created on 16 Jan 2020  路  10Comments  路  Source: microsoft/terminal

Version: 0.8.10091.0

How to move cursor using mouse ?

Issue-Question Needs-Attention Needs-Tag-Fix Needs-Triage

Most helpful comment

@RomeshA that's it ! Yes, i hope that windows new terminal can give us this feature as it's really really helpful at all

All 10 comments

@AmericanY We're going to need a little more context to try and understand what your problem is. Is there a particular commandline application you're trying to use the mouse to move the cursor in? Can you reproduce your scenario in the legacy console? What would you expect to happen, and what's actually happening?

@zadjii-msft thanks for replying me back. basically I'm using windows new terminal currently. and usually i move the cursor using the Arrow keys. so i would like to know if i can move the cursor by mouse directly ?

for example

let's say i typed this command ping google.com and the cursor is in the end of the command, Now, can i move the cursor using the mouse to put it after ping for example?

No, that's not something that won't work without cooperation of the commandline application that's running in the Terminal. For example, bash or cmd.exe. Those are the applications that are actually responsible for drawing the prompt and the input line. They would need to be modified to support clicking to set the cursor position. I'm not sure I know of _any_ shell application that actually supports that tbh. You can confirm this by trying to run the equivalent commandline in a legacy console window - note that that mouse doesn't work like that in shells there either.

vim is a classic example of a application that _is_ mouse aware. It currently doesn't work in the terminal because of #376 and #545.

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

Personally I think this would be a nice feature to have, just to note in regard to @zadjii-msft's comment regarding applications that support this, the Mac OS terminal app provides exactly this functionality (see https://support.apple.com/en-au/guide/terminal/trmlshtcts/mac under action 'Reposition the insertion point', basically Option+Click repositions the cursor)

I'd be curious _how_ that works from a technical point of view. Do they just like, send left/right arrow key presses to emulate moving the cursor as if it was done on the keyboard when the user clicks? Or is there tighter integration with the shell that's running? Does this work in _all_ shells in Terminal.app? Or is this a zsh-specific feature?

Not sure, but it could be something like the former, because it seems to work when I just tried it with zsh, bash and also csh. I wouldn't be surprised if there are edge cases where it doesn't reposition correctly, but my experience is similar to @AmericanY in that 99% of the time I would use that feature to edit something in the middle of a long command, and it seems to work fine for that

I dug a little deeper though and it seems like this is revisiting a discussion from a few years ago in VS Code - https://github.com/microsoft/vscode/issues/26401. It looks like they settled on an implementation based on sending key presses (https://github.com/microsoft/vscode/issues/44448) and I can confirm that the latest VS Code on Windows 10 supports moving the cursor in the integrated terminal using Alt+Click. So it would be great to match this functionality in Windows Terminal

@RomeshA that's it ! Yes, i hope that windows new terminal can give us this feature as it's really really helpful at all

BTW, i just checked and i can see that mouse is not performing normally over SSH connection. I tried to use it within vim over SSH and within htop and i see the terminal receive the click's wrongly .

Came here after seeing this tweet where it works in zsh:
https://twitter.com/leonte_dev/status/1264140864751878144
(don't want to be a caveman anymore 馃お)

Was this page helpful?
0 / 5 - 0 ratings