Ubuntu – How to achieve Mac-like use of CTRL and CMD keys on Apple Keyboard

apple-keyboardkeyboardkeyboard-layoutshortcut-keys

I'm very used to emacs-like ctrl+a to mean "home," and cmd+a to mean "select all." Similarly ctrl+e is "end", ctrl+d is "delete", ctrl+c does what I expect in Terminal, and probably a few more requisites I don't have on hand.

Of course Ubuntu is a little different. The ctrl key is functionally most paired with the cmd key, even though in physical keyboard layout the cmd key will bind to super.

So my first step was simply swapping cmd and ctrl by editing xkb since that restores 70% of the functionality I'm missing.

That mostly leaves begin/end/delete and related Mac-"control" functionality, but I don't know a good way to split the functionality or move some super obscure key over to ctrl to achieve this. I'm trying to find a cohesive strategy in general, but hacks are a step.

Ubuntu 14.04.

Best Answer

For fixing your terminal behaviour:

A straightforward way to achieve what you are trying to do, is to edit your home config files. For a bash terminal, you are looking to edit your readline config, which would be your .inputrc.

  1. Open up a terminal
  2. man readline This tells you most of your customization options. If you scroll to the bottom, it shows you how emacs mode is configured. More on that below.
  3. gedit .inputrc This is what you want to edit. It is loaded whenever you log in, and will customize your readline (what bash uses for input) behaviour.

How I solved a similar issue.

I had to do something similar because I use Vi Mode in Bash:

set -o vi
  • I also use Colemak.
  • Subsequently, I use a highly customized version of Vim.

My .vimrc configuration does not affect vi Mode for bash (and ZSH for that matter).

So I had to create a custom one, and boy was it a lot of work:

http://bazaar.launchpad.net/~akiva/colemak.vim/trunk/view/head:/.inputrc

You can use my code there as a template to work off of. I have all the functions there. The ones I do not use are commented out. You can map your characters to two things:

########
# Copy #
########
# Copy to
"c":    vi-yank-to 
# fake copy line
"C":    "0c$$"
  • vi-yank-to is a builtin function
  • "0c$$" is a custom string (Notice the quotes around it) that basically simulates me pressing 0, c, $, $ in that order.

Let me know if you have any questions.

Related Question