5

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.

1
+50

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.

  • Do you have an alternative for differentiate ctrl + c and cmd + c in terminal ? It's my main problem, the first should "cancel" the current line, and the second should copy. – chalasr Jan 1 '16 at 12:46
  • Go into terminal, and enter cat -- now, everything you type is returned to you. Type ctrl + c and cmd + c to see how how readline recognizes them. "c": can be replaced whatever the output brings out, and you can assign vi-yank-to to that sequence of characters. – Akiva Jan 4 '16 at 10:32
  • Using cat -- and hit <Ctrl+C> the process is killed. If I map the shortcut to another action (Guake), it will return ^C for <Ctrl+C> and same for <Cmd+C>. How can I interpret my CMD key, which is mapped to LEFT_CTRL same as my CTRL key, as a different key ? On OSX, Ctrl is used for all actions related to terminal, same as Linux, and Command is used for copy/paste and other actions related to the application like close a tab, quit terminal ... How can I reproduce this logic ? I'm not using vim-mode, but if it can help me to solve this problem, I can use it. – chalasr Jan 5 '16 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.