Something that's bugged me about OS X's Terminal is its default key shortcuts: the home and end keys don't do what I expect, and holding ctrl+arrow keys don't skip around words (which is really useful once you get in the hang of it). Even "cmd" from Windows has these key behaviors.
The fix:
Check out /etc/inputrc and /etc/profile to make changes system-wide (of course, you can make this specfic to only your user account by using ~/.inputrc and ~/.bash_profile).
This is my /etc/inputrc:
# Be 8 bit clean.
set input-meta on
set output-meta on
set convert-meta off
# allow the use of the Home/End keys
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# allow the use of the Delete/Insert keys
"\e[3~": delete-char
"\e[2~": quoted-insert
# mappings for "page up" and "page down" to step to the beginning/end
# of the history
"\e[5~": beginning-of-history
"\e[6~": end-of-history
# alternate mappings for "page up" and "page down" to search the history
# "\e[5~": history-search-backward
# "\e[6~": history-search-forward
# this lets you hit tab to auto-complete a file or
# directory name ignoring case
set completion-ignore-case On
# these allow you to use ctrl+left/right arrow keys
# to jump the cursor over words
"\e[5C": forward-word
"\e[5D": backward-word
and this is the relevant line in /etc/profile
export INPUTRC=/etc/inputrc
3 comments:
Wow. That was extremely helpful. :D
Thanks a lot for that!
This post is just so google finds this entry when I look for things like "key bindings" and "tiger" or "apple" or "bash"
Ok, here’s some more google-bait for keyboard bindings. (I just noticed that I don’t actually mention the word “keyboard” at all.)
Post a Comment