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 often use the ctrl-o shortcut in bash (from "Learning the bash Shell"):

[G]o back to [a command in history] and press CTRL-O instead of RETURN. This will execute the command and bring up the next command in the history file. Press CTRL-O again to enter this command and bring up the next one.

It seems this shortcut is not available on OS X; ctrl-o simply does nothing. A web search turns up the suggestion to use the ! bash builtin, but I don't see how I can accomplish the same thing as ctrl-o with it.

Is it possible to somehow get ctrl-o behavior in Terminal.app on OS X?

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Control-O is, for some reason (probably having to do with it being used for flow control on some kinds of serial connections) set to be discarded by the terminal driver (i.e. not Terminal.app, but the part of the OS between it and the shell). You can get rid of this with the command stty discard undef. To make this change permanent, add this command to your .bash_profile and .bashrc files.

share|improve this answer
    
Thanks for the tip, that did it! –  Mike Mazur Oct 18 '10 at 13:02
add comment

man bash might help. The "READLINE" and "Readline Key Bindings" talk about binding the key presses available and how to set up readline's defaults.

Also Bash Emacs Editing Mode Cheat Sheet and Working Productively in Bash's Vi Command Line Editing Mode (with Cheat Sheet) are good for figuring out what keypress does what if you are using vi mode instead of the default emacs. In either case bind -P | grep found will show you what key combinations are configured in vi mode and bind -P will show everything available.

share|improve this answer
1  
Wow, I had no idea there was vi-mode available in bash! This is beyond sweet. Thanks! –  Mike Mazur Oct 18 '10 at 13:07
1  
I felt the same way when I discovered it was available. –  Greg Oct 19 '10 at 7:29
    
me too me too :) –  Robert S Ciaccio Dec 4 '10 at 6:58
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.