Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In vim, you can use the option :set mouse=a, and then (if your SSH client supports it) you will be able to simply click and the cursor will move, rather than having to use the arrow keys or whatnot.

I realize that vim switches to the 'alternate screen'. I'm just wondering if there's a way to use such integration on the 'main' screen also. If so, are there any shell script interpreters that handle this?

Right now I'm using bash, and sometimes I type a quite long command, and have to correct something mid-way through. If there was an alternative to bash which was reasonable, or an extension to bash which handles mouse interaction I would be pleased. Do you know what I need to make this work?

Further I'm interested in mysql but let's start with the main command line.

share|improve this question
1  
I'm not familiar with a shell which allows for mouse support, but I did want to mention that BASH can handle vi keybindings, which at least makes it a bit easier. Here's an article to from vim's site: vim.wikia.com/wiki/Use_vi_shortcuts_in_terminal – DKing Jul 8 '16 at 17:22
1  
have you tried using Ctrl-X Ctrl-E to edit the current command line in your favourite editor. that's assuming you're using the emacs-like default keybindings. if you're using vi-like keybindings, use ESC v. If your editor can use the mouse, this will too. – cas Jul 9 '16 at 14:47
    
@cas, That makes for a good answer. :-) – George Bailey Jul 9 '16 at 15:25

bash has the built-in ability to call an external editor to edit the current command line you're working on. Mouse support depends on the editor used.

If you're using bash's emacs-like mode, use Ctrl-XCtrl-E to access the editor.

If you're using vi-like keybindings, use ESCv

You can also use the built-in fc command to edit any previous line.

$ help fc

fc: fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]

Display or execute commands from the history list.

fc is used to list or edit and re-execute commands from the history list. FIRST and LAST can be numbers specifying the range, or FIRST can be a string, which means the most recent command beginning with that string.

Options: -e ENAME select which editor to use. Default is $FCEDIT, then $EDITOR, then vi

[...]


BTW, one small annoyance with this (in any of its forms):

There may be some simple way to abort an edit or to make bash return to editing the line itself and NOT execute it immediately, but I've never found one (I haven't looked very hard).

Quit-without-saving just executes the line as it was before you called the editor.

The only way I've found is to delete the entire buffer in the editor, then save and exit. Or add a # comment at the beginning, of course.

PS: I use emacs-mode line editing and Ctrl-XCtrl-E for vim when i need real editing power. I don't know why, I love vi and vim, but I just don't like vi-mode on the command line.

share|improve this answer

Only the OS X terminal emulator can set the cursor position, when combining the left mouse button click with "Option".

For linux terminal emulators, this feature is not available/wanted as of Q3_2016.

There was at some point a request for the gnome terminal emulator to support this, but I do not think this feature is implemented (yet).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.