Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Does anybody know a better terminal program for snow leopard which allows for text editing? (i.e. jumping to a specific character without having to use the arrows to go one by one) etc..? thanks!

UPDATE: Sorry, I meant updating a command that was already written. Say I wanted to do something like script/generate migration add_field_to_something. I wrote that and Rails generated a migration. Now I decide that I want to get rid of that migration because I made some sort of mistake. To do so, I'll need to write script/destroy migration add_field_to_something. Right now, I have three options: 1) write the whole command from start to finish 2) Hit the 'up' button to reproduce the last command, and then the left arrow until I get to the word generate and then delete and write destroy, or 3) copy that last command into a TextEdit, select it with the mouse (or skip words with command + left-arrow to select faster - not possible in terminal) and then replace that with the word destroy, then copy back to terminal. My question is - is there a terminal program that allows for editing with the mouse/skipping words like I do in TextEdit (i.e. with command + left-arrow) to save time?


share|improve this question

migrated from stackoverflow.com May 10 '10 at 1:42

This question came from our site for professional and enthusiast programmers.

6 Answers 6

up vote 3 down vote accepted

Are you looking for an editor, or a terminal program? A terminal emulator is separate from an editor, and won't support the mouse pointer.


Thanks for clarifying. You may be interested in the zsh shell, which has a number of keyboard shortcuts for moving the cursor:

  • Alt-A - Move to the beginning of the line
  • Alt-E - Move to the end of the line
  • Alt-F - Move Forward one word
  • Alt-B - Move Backward one word

Also, bash, which is the default shell, has keyboard shortcuts for moving to the beginning and end of the line:

  • Ctrl-A - Move to the beginning of the line
  • Ctrl-E - Move to the end of the line
share|improve this answer
thanks - added a clarification. –  Yuval May 10 '10 at 2:20
Note that the default shell, bash, also supports emacs and vi style cursor movement, e.g. control-A for start of line, control-E for end of line. –  Paul R May 10 '10 at 7:51
@Paul R Thanks, I edited the answer to include the bash shortcuts you mentioned. –  pkaeding May 10 '10 at 14:10
@Paul: It's a pity bash doesn't allow for M-F and M-b... –  Brian Postow May 10 '10 at 14:38
It does. On the mac, it's option-F and option-B -- but make sure that in Terminal's preferences you have "Use option as meta key" checked. –  Doug Harris May 10 '10 at 14:41

There's a lot that you can do with command line editing within bash, the default shell. Note that this is independent of which Terminal program is used. There's lots of information about in the Command Line Editing section of the bash docs or checkout this screencast.

Update Per my comment on another answer, you can use M-f (option+F) and M-b (option+B) to go forwards and backwards by word. The screencast I linked to shows how to do that. It also discusses searching the command history using C-r (something I'd never tried).

share|improve this answer
thanks - added a clarification. –  Yuval May 10 '10 at 2:19
"Note that this is independent of which Terminal program is used." technically wrong: if the terminal is stupid enough, it will prevent you from doing many things. This isn't as rare a situation as one might think. –  Lohoris May 10 '10 at 14:26
@lo'oris: true, but mac's Terminal.app is not that stupid... –  Brian Postow May 10 '10 at 14:44
I agree with both Lo'oris and Brian Postow. Stick to Terminal.app and you shouldn't have any problems (and be sure to watch that screencast -- I don't know the person who made it, but it's nicely done) –  Doug Harris May 10 '10 at 21:37

There are all sorts of tips and tricks in the shell where this sort of thing is just as quickly fixed with shell keyboard shortcuts and commands.

For example, using the zsh shell and your sample scenario, you have a 4th option:

zsh% script/generate migration add_field_to_something

Oops! I didn't mean to do that. Let me type this…

zsh% script/destroy !*

Fixed! the !* means: use all the parameters from the previous command.

Alternatively, you could have just typed:

zsh% r generate=destroy

The r command means replace in the previous command. So, the previous command would be run with generate replaced with destroy.

I guess what I'm saying is that programmers are lazy. Very lazy. They've thought of hundreds of shortcuts and auto-completion tricks to make these jobs quick and easy. Once you learn how to use a shell, and optimize it, you might see that "fixing" commands using mouse selection is perhaps not the most efficient route…


A lot of rails developers also set up an alias file in ~/.zsh that's called from their .zshrc.

alias sg='script/generate'

So, that would save even more keystrokes. script/destroy you might want not to alias, just to avoid accidental invocation. ;-)

share|improve this answer

I prefer iTerm for terminal operations in OSX. http://iterm.sourceforge.net/

The terminal allows for mouse interaction (via standard xmouse) and has many bells and whistles standard terminal does not have.

share|improve this answer
Is there a way to use the mouse to click into a command line for editing? I've been trying and don't see how. –  Doug Harris May 10 '10 at 14:56

Another option is to use emacs shell-mode. if you're familiar with emacs, you can type M-x shell-mode it will give you a normal prompt. you can use all of the normal emacs editing commands.

ONE WARNING, since up arrow (or C-p) actually moves the cursor up a line, you need to use M-p and M-n to get the previous and next commands...

For all I know vim may have a similar mode, but I'm a true believer in the cult of Emacs so...

share|improve this answer
Upvoted because it's a good solution for fellow cult members (like me) or for those considering climbing the Emacs learning curve. This is one more reason to join us. I don't think this alone would justify switching to Emacs. –  Doug Harris May 10 '10 at 14:58
@Doug Oh, clearly not. I mean, it's basically evidence that emacs is an operating system, not an editor but yeah... B-) –  Brian Postow May 10 '10 at 15:39

Use vi as your editor (export EDITOR=vi) and then set your shell to use vi mode (set -o vi) and after that, you're golden. Want to recall that huge line you had, hit esc and forward slash to start a search through your command history. Type the first couple of characters that you entered. Cycle though them by hitting forward space and then enter. Enjoy.

share|improve this answer

Your Answer


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.