Any terminal shell with mouse support?

7,574

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.

Share:
7,574

Related videos on Youtube

isarandi
Author by

isarandi

Updated on September 18, 2022

Comments

  • isarandi
    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
      JdeBP almost 6 years
      Midnight 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
      isarandi almost 6 years
      I 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
      JdeBP almost 6 years
      That 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
    isarandi almost 6 years
    This 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
    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
    Admin almost 2 years
    This 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
    Admin almost 2 years
    For 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.