Add an Insert key in Terminal and X11's xterm

Feb 21, '08 07:30:02AM

Contributed by: calvin.folds

I need an insert key to work with my company's custom software, not to mention all the little annoying little Unix programs that expect a INS key. With X11 apps, its easy to use xmodmap f12 to temporarily emulate an insert key. Just type the following in xterm:

xmodmap -e "keycode 119 = Insert"
Now the F12 key acts like insert in all X11 apps, as long as you run them from the terminal. The best part is that keyboard settings go back to normal as soon as you close the Terminal, so you don't have to worry about changing it back. That's all well and good, but I prefer to use the Mac's Terminal.app when possible. Fortunately it's pretty easy to emulate an INS key there, too. In Terminal.app's Preferences, go to Settings and select Keyboard. Find the Key you want to replace -- in my case, F12 -- and change the default Action value to:
\033[2~
Note that the \033 is the Escape key, not those literal characters. I haven't been able to find a way to easily revert the setting, but I don't tend to need the F12 key in the Terminal, so I just leave it.

[robg adds: As submitted, the hint contained the actual key sequence and instructions to copy and paste it into Terminal. However, between Geeklog submission and publication, something munged the string, so I had to remove it. Theoretically, you should be able to type Escape followed by [2~ and make this work. However, I created the sequence by editing the existing definition for F12 (double-click it), as it ends in 24~. In the edit box, there's a Delete One Character button, so I clicked the mouse to the right of the 4, then clicked the button to delete one character. However, I'm unsure about testing the functionality of this keystroke, as I rarely use X11 apps.]

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20080122065954390