16

For example, if I find I miss one letter in a long command, currently I need to press ← to move the cursor, which is slow. Why can't we use mouse to put the cursor in the place we want?

4
  • 1
    Did you try Ctrl - left or Ctrl - right?
    – user85164
    Oct 16, 2013 at 4:48
  • 1
    Thank. I knew it. I hope a more flexible move. I think the mouse is much more convenient. I find the python console in PyCharm is as friendly as an editor. But how about other terminals? Oct 16, 2013 at 5:27
  • 1
    I would love to know if this was possible with gnome-terminal. Apparently you can do so in OSX: news.ycombinator.com/item?id=7051091.
    – Fern Moss
    Jan 14, 2014 at 6:24
  • For native terminal, you will probably have no luck. See the mouse section in the terminal howto of The Linux Documentation Project.
    – Izzy
    Jan 16, 2014 at 21:58

5 Answers 5

8
+50

Use emacs.

sudo apt-get install emacs

Upon the install, start emacs: emacs

Press Alt+X, and type term and press Enter. Voila!

You have a terminal where you can change the cursor position with mouse.

If mouse click does not change the cursor (in 99% of the cases, it will, by default), then put (xterm-mouse-mode t) in your .emacs file:

echo (xterm-mouse-mode t) > ~/.emacs
2
  • Since there doesn't seem to be a way with gnome-terminal, this seems like the easiest method.
    – Fern Moss
    Jan 20, 2014 at 2:45
  • I just tried the method. The mouse click does not change the cursor. Then as instructed, I put: echo (xterm-mouse-mode t) > ~/.emacs; The error information is: bash: syntax error near unexpected token `xterm-mouse-mode' (I use Ubuntu 16.04) Aug 14, 2016 at 16:27
4

The terminal itself can take mouse input. You can test this opening a text file with nano and enabling mouse

(M-M)                   Mouse support enable/disable

(On my keyboard that's ESC+M.)

Then you can change the position of the cursor by clicking.
If you are asking about changing the position of cursor in the SHELL, there was a discussion in ubuntuforums mentioning gpm. There is also a duplicate of this question in stackoverflow with some alternatives proposed.

2
  • 1
    The question is about the shell, specifically moving the cusor position (since you can easily select text with the mouse, for instance, in gnome-terminal).
    – Fern Moss
    Jan 14, 2014 at 19:53
  • why the downvote? The original question was a bit ambiguous. Jan 21, 2014 at 9:11
1
echo -e "\e[?1000;1006;1015h" # Enable mouse tracking

Script : I made a bash script to move bash readline cursor on mouse click on my github

Details : Read my answer in another post

0

In vi mode (when the the command line behave as vi, enabled by set -o vi) you can launch a full vi to edit the current line: Pass in command mode with ESC, then press v. and in vi you should be able to use your mouse to move to the expect character.

I don't know if this kind of command exist for the emacs mode (set -o emacs), the default one.

0

You can use jupyter qtconsole with the bash_kernel to accomplish this! Follow the install instructions at github repos in the links provided, then from the terminal run

jupyter console --kernel bash

This will launch an new window with a versatile and powerful shell that has

  • mouse cursor positioning
  • text selection and editing
  • autocomplete
  • history
  • so much more

You must log in to answer this question.

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