Possible Duplicate:
How can I move around the bash commandline efficiently?

After googling for some Mac OS X terminal shortcuts, I wanted to find how can I go back characters on a line on the terminal or words or similar. I found ALT + B but it does not work.

Do you know some other shortcuts, or how can I customize them or links to cheat sheets?

link|improve this question

duplicate: superuser.com/questions/113103/… ... not OSX specific but does provide a lot of information about standard bash keyboard mappings, customizing readline, and other fun bash tricks. – quack quixote Mar 26 '10 at 17:35
2  
this is not a duplicate of the above question. this one is about how to get OSX not to catch key bindings that are bound for the terminal – Arthur Ulfeldt May 13 '10 at 18:57
1  
Please unmark this as duplicate. It needs an answer indicating 'use option as meta key' for OSX terminal. – bentford Nov 8 '10 at 21:24
feedback

closed as exact duplicate by quack quixote, Ivo Flipse Mar 27 '10 at 15:19

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

2 Answers

up vote 3 down vote accepted

You want the READLINE section of the bash(1) man page:

man 1 bash
/^READLINE
link|improve this answer
feedback

Mac OS X's terminal is BASH, here's some BASH shortcuts:

Ctrl + A    Go to the beginning of the line you are currently typing on
Ctrl + E    Go to the end of the line you are currently typing on
Ctrl + L    Clears the Screen, similar to the clear command
Ctrl + U    Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H    Same as backspace
Ctrl + R    Let’s you search through previously used commands
Ctrl + C    Kill whatever you are running
Ctrl + D    Exit the current shell
Ctrl + Z    Puts whatever you are running into a suspended background process. fg restores it.
Ctrl + W    Delete the word before the cursor
Ctrl + K    Clear the line after the cursor
Ctrl + T    Swap the last two characters before the cursor
Esc + T  Swap the last two words before the cursor
Alt + F  Move cursor forward one word on the current line
Alt + B  Move cursor backward one word on the current line
Tab      Auto-complete files and folder names

The one you are looking for is Ctrl + H. (This is the same as hitting the backspace key)

If you are looking for an escape character to go back one character, you are looking for \b. As in:

$ echo -e "one two\b\b\b\b three" # Will echo "one three"
link|improve this answer
4  
To get the “Alt” bindings to work, the user will have to enable “Use option as meta” in Terminal. This will replace the usual Option-based extended characters and dead keys. – Chris Johnsen Mar 26 '10 at 15:54
2  
Sidenote: Using alt as meta key makes many needed characters like @[]|{} unaccessible on many international keyboard layouts like german or austrian. You can jump forward or backwards a word by pressing ESC-f and ESC-b respectively. For single characters you can use the arrow keys in most cases. In Terminal.app: Preferences > Settings [Advanced] you can tick a box to "Delete sends Ctrl-H" to have your delete key behave correctly in apps like vim. – MacLemon Mar 26 '10 at 18:51
-1 This does not answer the question. Chris Johnsen answered correctly, but in a comment. – bentford Nov 8 '10 at 21:22
The alt commands doesnt work for me Alt + F, and Alt + B doesnt work. I am running bash – Shervin Oct 20 '11 at 11:23
feedback

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