Score:1

Place Cursor at Mouse Position on Terminal with an Option+Click in terminal doesn't work

to flag

In Ubuntu terminal I can see placing Cursor at Mouse Position on Terminal with an Option+Click works.

The same works in other linux terminal from Mac. For example reference : https://www.bollyinside.com/articles/place-cursor-at-mouse-position-on-terminal-with-an-optionclick/

Is there a way to achieve this in Ubuntu?

Terrance avatar
id flag
Possibly related: https://superuser.com/questions/1081310/how-to-move-the-commandline-cursor-on-bash-using-the-mouse
cn flag
"linux terminal from Mac" - what do you mean by that?
cn flag
"In Ubuntu terminal I can see placing [...]" - did you mean Mac instead of Ubuntu here?
Score:0
cn flag

The terminal rxvt-unicode moves the cursor to the mouse position with Shift-Click.

This will behave exactly the same at Option-Click does in the Mac terminal.

Score:0
cn flag

By the very nature of how terminals work, the cursor is "owned", controlled by the application that's running inside. The cursor denotes the next position where the application's output will be printed at.

Should you somehow forcefully modify this position in the terminal, unbeknownst to the application, most likely subsequent output printed by the application will corrupt the screen big time.

What a few terminal emulators do is that they try to guess what keypresses to synthesize towards the application, so that in response the application will end up moving the cursor to the location where you wish to.

Any such heuristic has obviously very limited use, and is likely to break pretty often. How would the terminal know which application is running? Using hacks like digging into /proc or equivalent, which stops working across an ssh, tmux or other similar layers? If it knows what application is running (e.g. a shell or a text editor), how would it know what state that application is in (e.g. is the shell running a command or waiting for you to type a command? If the latter, is it perhaps in some special mode of readline? If it's a text editor, are you editing a file or are you in some other mode (e.g. a command line, a dialog etc.)? Does it have split screen, and do you need to jump to a different panel?) Shall we begin to teach the behavior of some well-known applications to the terminal? Hopeless.

No wonder that only very few terminal emulators try to offer you this convenience feature. I haven't tried this feature yet in any of them, but I'm pretty sure I'd find a plethora of bugs in just a few minutes. It's impossible to reliably know which keypresses need to be emitted so that the applicaton's response will be to move the cursor to the spot you requested. Any work that any terminal offers you is necessarily a fragile guesswork.

I'm not sure what you mean by "Ubuntu terminal", but based on the tags of the question you probably mean GNOME Terminal. Like the majority of the terminals out there, GNOME Terminal doesn't attempt to address the impossible.

You should get familiar with the power features of the applications you're using. Does the application support mouse? Maybe you need to enable it, and then the application receives mouse clicks and most likely moves the cursor there. If not, are there any keyboard shortcuts that move the cursor in bigger steps? E.g. Ctrl+Left, Ctrl+Right to jump by words? Newer versions of bash and readline can jump up and down to the next visual row, which I've personally connected to Ctrl+Up, Ctrl+Down. Etc. There's no "one size fits all" solution for repositioning the cursor.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.