To configure the Home and End keys in terminal on MacBook Air (OS X 10.7.2) I defined in Terminal -> Preferences -> Keyboard:

Key     Action
----    ------
Home    \033OH
End     \033OF

What are the codes to configure the following combinations so that they will work like in Windows?

  • Shift+Left (should select the character on the left)
  • Shift+Right (should select the character on the right)
  • Shift+Home (should select all the characters on the left)
  • Shift+End (should select all the characters on the right)
link|improve this question

2  
You do realize that xterm and Terminal.app are not the same? – Daniel Beck Nov 18 '11 at 11:30
I'm not sure... Could you explain please? How does this help me to do the desired keybindings? – Misha Moroshko Nov 18 '11 at 11:52
It doesn't. But your question is misleading: There's absolutely no connection to xterm with what you want to do. – Daniel Beck Nov 18 '11 at 12:16
OK, I deleted xterm from the question. – Misha Moroshko Nov 18 '11 at 12:21
What kind of selection are we talking about, do you mean the terminal selection (when click and drag with the mouse), or the shell selection (when you press C-space). They are different. – Ammar Abdulaziz Feb 1 at 18:12
feedback

1 Answer

You can use the read command to determine the keybinding sequence followed by your required keys

Add the output to the below file prefixed with "\e[your sequence]"

Create a file in your home directory ~/ called .inputrc

$ vim ~/.inputrc

I have the following setup for ctrl + left , right, up, down and home and end keys

"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": history-search-backward
"\e[6~": history-search-forward
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word

Restart Terminal.app and your good to go.

link|improve this answer
3  
The question is about selection, not movement. – Daniel Beck Nov 18 '11 at 17:11
feedback

Your Answer

 
or
required, but never shown

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