Terminal: map super/command key in stty
I want to remap terminal shortcuts (In particular, I want to remap INTR
from CTRL+C
to Command+C
) in Terminal.
So these are my current stty bindings
$ stty -a
speed 38400 baud; 38 rows; 179 columns;
lflags: icanon isig iexten echo echoe echok echoke -echonl echoctl
-echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
-extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel iutf8
-ignbrk brkint -inpck -ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
-dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
stop = ^S; susp = ^Z; time = 0; werase = ^W;
And for example if you want to remap something it'd be like
stty intr \^c
Which maps SIGINT
to CTRL+C
But I want to map SIGINT
to COMMAND+C
. Something like this (which is invalid):
stty intr ⌘c
Now I know that the terminal doesn't really recognize the Command key, but is there a creative way of doing it?
Note: I know it can be done with ITerm2 but am wondering if there's a way to do it with the vanilla Terminal.
Thanks
@Niklas I solved the problem, but not using stty. Instead, I've been using Karabiner-Elements to do custom configuration on the Terminal keys (without affecting the rest of my bindings).
Basically you install the Karabiner-Elements app and then write a "complex modifications" rule in the karabiner.json file to swap whatever you want. Here is a guide on how to configure the json config.
My karabiner.json looks something like this:
{
"name" : "com.apple.Terminal",
"simple_modifications" : {
"left_option" : "left_control",
"left_command" : "left_option",
"right_control" : "right_command",
"right_option" : "right_control",
"right_command" : "right_option",
"left_control" : "left_command"
},
"complex_modifications" : {
"rules" : [
{
"manipulators" : [
{
"to" : [
{
"key_code" : "c",
"modifiers" : [
"left_command"
]
}
],
"type" : "basic",
"from" : {
"key_code" : "c",
"modifiers" : {
"mandatory" : [
"left_control"
],
"optional" : [
"any"
]
}
}
]
},
... more rules for all the stty characters, etc
]
}
}