Any terminal shell with mouse support?
zsh
can be extended to support mouse operation like you describe, using Stéphane Chazelas’ mouse.zsh
ZLE widget:
wget http://stchaz.free.fr/mouse.zsh
. ./mouse.zsh
zle-toggle-mouse
(and once you’ve tested it, add it to your ~/.zshrc
).
It will work in any terminal with VT200 mouse tracking, and in the Linux console with gpm
.
Related videos on Youtube
isarandi
Updated on September 18, 2022Comments
-
isarandi over 1 year
Is there any terminal shell/emulator out there that supports editing your current command with the mouse?
Specifically things like placing the cursor by clicking (useful for long commands) or double clicking and pressing delete to select and delete a word etc.
For example, the terminal at the bottom of Midnight Commander (mc) has support for placing the cursor by mouse click. I'm looking for something similar that is more terminal-focused, as mc is mainly a file manager.
It's fine if it only works under a GUI environment (I'm on Ubuntu 18.04 with GNOME3).
-
JdeBP almost 6 yearsMidnight Commander is as much a terminal application as any other, and what you are looking for is shells, that understand mouse input because their ZLE/libedit/Readline libraries do. The terminal emulators have provided mouse input capabilities for years. What you are looking for is shells that enable and understand such input.
-
isarandi almost 6 yearsI could also imagine a terminal emulator (use whatever word) that would fully work like a normal GUI application, say like MATLAB, where you can properly edit your command in the modern way with a thin line cursor, right click menus etc., then press enter and then the whole line would be given to bash as one command. However I can see how this would be problematic for interactive terminal applications. I'm just brainstorming because I find the current ways quite inconvenient.
-
JdeBP almost 6 yearsThat wouldn't work, ironically because the ZLE/libedit/Readline libraries would get in the way. In the POSIX General Terminal Interface architecture, editing is either a function of the applications softwares themselves (such as shells with ZLE/libedit/Readline) or of the line discipline when in canonical mode. Terminals are not block mode and there is no local editing. What you are looking for is shells where the editor library knows about mouse reports.
-
-
isarandi almost 6 yearsThis goes in the right direction, but unfortunately the mouse can either be used to edit the current command or to select text from previous outputs but not both at the same time.
-
Stephen Kitt almost 6 years@isarandi it’s a bit complicated to provide both simultaneously in this kind of context, within an existing terminal. If you bind
zle-toggle-mouse
to a key, as suggested in the documentation, you can toggle the behaviour even while you’re editing a command, which alleviates the problem somewhat... -
Admin almost 2 yearsThis doesn’t answer the question: the OP is looking for the ability to edit the current command with the mouse (at minimum, place the cursor), which
gpm
doesn’t provide. -
Admin almost 2 yearsFor the record, I (the author) never really used it in the end. It was more to see if it could be done. It was also written almost 20 years ago, it could probably be improved to use newer features of zsh. I've noticed a few forks on github with some improvements. IIRC it was pulled into oh-my-zsh at some point, I don't know if it's still there.