7

Is it possible to get programs using GNU Readline (e.g. Bash, the Python REPL, or anything else that responds to ~/.inputrc) to let you edit the current line using the mouse? For example, I’d like to be able to click at a specific place in the line to move the cursor, or select a region of text.

I suspect the answer is “no, this is not supported”, given that I have found no useful Google results about Readline (the best I’ve found is mouse support in ZSH, which is nice because I do use it as my shell but it doesn’t help with other Readline programs), but I also haven’t been able to confirm that.

The closest I've found to this kind of thing in arbitrary Readline programs is that some terminal emulators attempt to detect when Readline is active and emit arrow-key sequences on click. I'd rather have this handled by Readline if possible, both because I expect it would do a better job and because I like the terminal emulator I currently use, which doesn't support that.

1 Answer 1

5

Does that work ? It should print escaped sequences on your terminal when using the mouse

echo -e "\e[?1000;1006;1015h" # Enable tracking

If it works : test my script on github

Details : Read my answer in another post

3
  • 1
    This looks like it would work in Bash but would need to be re-written for each Readline-enabled program, is that right? And I don't think Python for example even has a way to programmatically set the point.
    – Daniel H
    Mar 31, 2019 at 5:18
  • True : works only on bash and ipython. I don't know why ipython but I guess because it has been well written. I may improved that in the future wih only modifying .inputrc so it would work on perl reply for example.
    – Tinmarino
    Mar 31, 2019 at 14:01
  • 1
    @DanielH : It has already been written for python : run : ipython --TerminalInteractiveShell.mouse_support=True look there : github.com/prompt-toolkit/python-prompt-toolkit/blob/master/…
    – Tinmarino
    Apr 1, 2019 at 15:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .