I want to change the functionality of some keyboard shortcuts, and add some custom ones, to Terminal in OSX such that:
alt + deletedeletes one word to the leftcmd + iselects my entire input
I have entered "Terminal" -> "Preferences" -> (selected profile) -> keyboard, and see a table that I can't decipher. I also can't find anything on google that maps the esoteric symbology to "actions" (I assume that 033円[3~ means "delete," for example).
How can I change the shortcuts of terminal to achieve my 2 goals above, or, where can I find a guide to map the symbols displayed in my example above (also see image) to "actions?"
Screenshot of Keyboard Preferences
This question is not related to adding keyboard shortcuts for OSX terminal or xterm because I am not trying to assign a bash function / command to a key.
1 Answer 1
The best way I aware of changing default keyboard/mouse behavior is Karabiner.
You can do
alt + deletedeletes one word to the left
- Install Karabiner. It is really handy tool for key mappings.
- In
Preferences>Complex Modificationsclick onAdd Rule - Now click on
Import more rules from the Internet - In the browser window that will open click on
Application Specific - Against
Navigation in Terminal Appsclick onImportbutton - You will be asked to open the downloaded file, do it in
Karabiner.app - You will see a list of options. Import them.
- Now in
Preferences>Complex Modificationsclick onAdd Rule - Against ⌥ + ⌫
Delete one wordclick onEnable
As for
2.
cmd + iselects my entire input
MacOS Terminal app does not allow to select text without mouse (unless you want to select all text in the current window with ⌘+A). So if you want to select text you need to emulate mouse.
You can add this code to karabiner.json to produce triple click.
{
"description": "⌥ + i | Select current line",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.apple\\.Terminal$",
"^com\\.googlecode\\.iterm2$",
"^co\\.zeit\\.hyperterm$",
"^co\\.zeit\\.hyper$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "i",
"modifiers": {
"mandatory": [
"option"
]
}
},
"to": [
{
"pointing_button": "button1"
},
{
"pointing_button": "button1"
},
{
"pointing_button": "button1"
}
],
"type": "basic"
}
]
},
Those "actions" are terminal escape sequences. They are really ancient. 033円 is escape character, followed by some other key codes. So basically this are key mappings.
-
Wow, you really know your stuff! This obviously fulfill the bounty.Caleb Jay– Caleb Jay2017年10月03日 18:44:52 +00:00Commented Oct 3, 2017 at 18:44