Ubuntu – How to change ^ modifier in Ubuntu terminal to be tied to Alt key

keyboard-layoutshortcut-keys

EDIT 2

First, look at the bold part of my EDIT at the bottom! I think the original way I posed the question is confusing people.


I've followed the instructions here to switch my Alt and Ctrl keys. Now when in a terminal I want to press the physical Ctrl+C to cancel. But the new mapping means I physically press Alt+C.

I looked at the keyboard shortcuts for the terminal:
enter image description here

and can't find that shortcut there.

I am on Ubuntu 20

EDIT

I realised I might be confusing the problem by telling you I originally switched my Alt and Ctrl keys. You can mostly forget about that if it makes it easier. Think of the question as: "Instead of pressing ctrl+key in the terminal for things like process interruption (ctrl+C) or reverse search (ctrl+R) I want to press alt+key. How can I set that up without actually changing the system-wide key bindings in general?"

EDIT 3

Finally, if it helps to understand my motivation for wanting to do this: right now, under my key mapping I have to physically press Shift+Alt+C to copy from the terminal, whereas in every other app that I use I just press Alt+C. After months I still can't get the hang of mentally adjusting. I end up pressing Shift in my other apps, or cancelling things in my terminal by forgetting to press Shift in the terminal. It's driving me insane!

Another point on my motivation. I'm coming from being a mac user, where in the terminal you have to press physical Ctrl+C to cancel, and physical Cmd+C to copy. On a standard non-mac keyboard, the Cmd is in the same place as the Alt. That's why I've done my key mapping this way.

Best Answer

'How to swap alt-ctrl in the terminal?'

OS X has a handy feature that allows Command as Ctrl.
Basically Ctrl and C like key nodes can be understood by the terminal but Super can't be the same.
See https://superuser.com/questions/1178542/super-key-notation-for-stty

  • You can edit stty -a for example stty intr ^K now Control+K is an interrupt key and you lose ^K used to erase towards the end of line. But you can't do it any other mod keys Alt Esc.

  • In the other words, it is very risky to change the default key bind, for example, someone tries to replace ^M works as other things than "Return" and you can't execute any commands.

  • You can change other shortcuts in Terminal, they are shown in the shortcut menu on your question.

  • I recommend leave the principals (^C or ^R) untouched and change all other things.


Swap Ctrl and Alt systemside.

First reassign the Ctrl and Alt as you describe, using xmodkey or Gnome-Tweak Typing setting

Tweak

I believe you already did this. Many other ways introduced
setxkbmap -layout 'us,us' -option 'ctrl:swap_lalt_lctl'

Using Alt key like the mac command (⌘) key for copy/paste


Swap physical keyboard layout

Now then, your Alt_L key is working as your Ctrl_L, and vice-versa.
Some keyboards are not allowed to replace keycaps, e.g. HHKB Pro cannot be done due to the different unit size.
However, most of keycaps are physically swap-able.

swap

[ctrl_c2