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.

djechlin
  • 168
  • 8

2 Answers2

1

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.

Anon
  • 11,863
  • 22
  • 66
  • 122
  • 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 01 '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. – Anon Jan 04 '16 at 10:32
  • Using `cat --` and hit the process is killed. If I map the shortcut to another action (Guake), it will return `^C` for and same for . 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 05 '16 at 14:05
0

This will make you keyboard works like Mac.

Remaps Left Ctrl with AltGr

sudo vi /usr/share/X11/xkb/symbols/ctrl

Change the section

// Map Ctrl to the left Alt key, Alt to the left Win key, // and Super to the left Ctrl key.

when it says "replace key " with

replace key { [ ISO_Level3_Shift ] };

Open Tweaks On Additional Layout Options -> Ctrl , mark "Map Ctrl to the left Alt key, Alt to the left Win key, and Super to the left Ctrl key."

On your shell configuration .zshrc in my case, remap to intr check if you have the cent symbol there before. Add this to the file :

stty intr 0xA2

On gnome-terminal remap the copy and paste shortcuts to "Ctrl C" "Ctrl V"

And move physically your keys to make sense