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.

In Terminal, Option + click allows me to place my cursor at any point on the current line-- great for editing really long commands.

How can I do this in iTerm2?

Update: According to this page, the feature has been around since 0.7.0 (2003). I've also noticed that if I hold Command+Option, the cursor changes into the familiar cross like in Terminal... but clicking still does not reposition my cursor.

share|improve this question
    
I had a look at the source code and yes the feature was around in 0.7.0 of iTerm (not iTerm2). But is commented out (in file PTYSession.m) in the trunk (and probably earlier versions too). And it iTerm2 the function is still there but empty and therefore doesn't do anything. –  boretom Mar 10 '12 at 23:46
add comment

4 Answers

up vote 5 down vote accepted
+50

I was wondering "How Hard Can It Be(c)" to implement it and gave it a go today.

The Terminal.app seems to emulate 'move cursor to left/right' ESC sequences. You'll hear the famous 'beep' if you try to place the cursor in the shell prompt. And you'll hear it as many times as there are invalid moves.

The solution in iTerm2 works the same by invoking the appropriate ESC sequences. Although it beeps only once if you try to place the cursor in an invalid area ;)

Terminal.app seems not to be able to handle multi-line prompts, only moving on the last line seems to work. Multi-line prompts in this implementation should be handled correct.

Results can be found on github. It's a fork of the original with a pending pull request. The branch I work on is named 'option-click-hardcoded'.

And of course it's highly untested. That means tested only by me on my late-2007 MacBook Pro running Mac OS X 10.7.3.

If you'd like try it out by compiling it yourself or download the precompiled binary for i386/x86_64/ppc iTerm_v1.0.0.git-085ec22c.zip).

share|improve this answer
    
wow, great stuff! pre-compiled binary seems to work fine on my end so far but will keep an eye on it. thanks a million! –  Jeff Mar 11 '12 at 22:58
add comment

iTerm 2 is not a new version of iTerm - while based on the same source code, there are major changes under the hood. One of the things that was removed or broken (hard to speak to the developer's intent) was cursor positioning.

You're not the only one who noticed this omission; it's been filed as a bug since April 2011 and continues to attract attention. Your best option for getting this feature (besides forking it on GitHub or switching to another application) is to submit a comment at the Google Code site above. Hopefully with enough interest, this feature will make it back into the product.

share|improve this answer
add comment

This is no longer working in the latest build, you'll have to go back to https://code.google.com/p/iterm2/downloads/detail?name=iTerm2-1_0_0_20120726.zip

as mentioned in the original ticket that got the feature added: https://code.google.com/p/iterm2/issues/detail?id=789

share|improve this answer
add comment

The latest builds now include this feature, as of March 15 2012.

Official Download site: http://code.google.com/p/iterm2/downloads/list

The latest build (Currently March 26th 2012) includes this feature.

share|improve this answer
    
thanks for the update! –  Jeff Jun 1 '12 at 14:19
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.