Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I work on a terminal most of the time.

Is there an application / plugin over iTerm or any other terminal like application using which I can control the cursor location of my terminal using a mouse ?

share|improve this question
    
What do you want to do at the cursor? –  Mark Feb 23 '11 at 15:49
1  
I would like to jump to the cursor. Use case being, If I have a long line delimited by space, I would like to jump to a particular location. using the keyboard takes many keystrokes. –  Sairam Feb 23 '11 at 16:11
    
If you are already using Terminal you probably appreciate the keyboard. Learn the keyboard shortcuts to jump to front/back of line, and navigate by word, and it will save you many keystrokes and probably be faster than the mouse. –  user588 Feb 23 '11 at 16:23
add comment

4 Answers

At least in Terminal.app you can hold down option while clicking to jump within your current line (that actually means just the line, so if your current prompt is so long that it wraps to a second line of input you'll have to option-click to the beginning of the "second" line and then hop with the arrow keys to the "first" line where you can option-click again.)

share|improve this answer
    
Option click, interesting. Never knew that one before. Be sure to click on the line though, holy crap. I don't even understand what's happening when I click above/below the current line. I assume it's pressing up a number of times, but I'm pretty sure the command history isn't exactly matching up. –  Jason Salaz Feb 23 '11 at 18:49
    
Well, it´s only reading the number of columns where ever you click and jumps to that position in the current (!) line; so if you are at the end of a wrapped prompt (say line 2: column 45) and you option-click on something in the first line (say line 1: column 4) you will end up in column 4 (great) but will stay in line 2 (wrong!). –  Asmus Feb 24 '11 at 6:39
1  
The way Option-Click works is that it issues the equivalent of arrow key inputs. This works well in editors like emacs, but if you're at the bash command prompt, it interprets up/down as "previous/next command in history". So, if you Option-Click anywhere except the same row that contains the prompt, bash goes through your command history instead of moving the cursor. –  Chris Page Aug 14 '11 at 2:06
add comment

The keyboard is often your best friend. In a default configuration, your shell controls much of how you navigate around the command prompt.

Option + b goes back a word (the cursor will end up at the first letter of the previous word).

Option + f goes forward a word (the cursor will be at the non-letter character AFTER the next word).

Shift + Fn + Left Arrow (←) will put the cursor at the very start of the line. (Ctrl + a will also do this.)

Shift + Fn + Right Arrow (→) will put the cursor at the very end of the line. (Ctrl + e will also do this.)

So if I have a long command, for example:

$ rsync -avz --progress ~/Sites/Development/My/Project web@server:/deployment/output/area

And I start hitting Command + b, the cursor will stop on the a in area, the o in output, the d in deployment, etc.

If I go to the start of the line, and start hitting Command + f, the cursor will stop at the space after rsync, the space after avz, the space after progress, the / after Sites, etc.

share|improve this answer
add comment

If you are specifically interested in movement in Vim, then you can add set mouse=a to your ~/.vimrc file.

It does work in iTerm for movement. It also allows you to mark sections as if you had entered visual mode, so that you can yank or delete it or comment out code depending on your plugins.

Very conveniently it also lets you quickly scroll through a large document using a two-finger slide or mouse wheel.

The only drawback is that it makes it difficult to select text that you want to copy for use in other applications—though all you have to do is press option while you select.

Also: note that, if you add something like vimpager (also on macports), then you can also scroll through man pages once you add:

export PAGER=/opt/local/bin/vimpager #or wherever vimpager is installed
alias less=$PAGER

to your .profile or .bashrc.

share|improve this answer
add comment

It's quite a time since this question came up and I did already mention the below on this platform in Option-click in iTerm and the issue tracker of iTerm2 but maybe it's of help for one or the other:

Hi, just wanted to let you know that I implemented that feature in iTerm2. It's not yet in the official iTerm2 repo but if you'd like to give it a go, you can find it at github.

Since it's tested only by me consider it not-stable. I did test it with bash, vi and emacs and did my best to resemble Terminal.app behavior.

There's a precompiled binary on github too iTerm_v1.0.0.20120312.git-b919985b.zip (for i386/x86_64/ppc).

Of course any feedback is welcome.

share|improve this answer
add comment

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.