27

I'm still switching back and forth all the time from Linux to Mac, and I can't figure out how to stop getting confused in my keystrokes, especially with browsers, and Unix apps.

Here's the situation:

  • Emacs, vim, shell, and other Unix apps use the ctrl key the same on both Mac and Linux
  • Some VERY common keystrokes of copy, paste, cut, all are swapped cmd on the Mac, and ctrl on Linux.

Some things I tried:

  • Using cmd as ctrl in Emacs — kind of works, but then it confuses other Unix type apps.
  • Swapping the position of cmd and ctrl on the keyboard — good for copy, paste, all, and not much else.

I can't possibly be the only one that goes back and forth between Mac and Linux having this issue.

Would it possibly be better to approach this from the Linux side and change the mappings there so that I can have the same ones on the Mac?

The main problem is browser apps (Chrome/Firefox) and then Unix type apps (Emacs, IntelliJ, Rubymine, Vim, tmux).

4 Answers 4

5

After a number of months, I did come to a solution that I like.

  • On the Mac, I got used to the fact that there are 3 main modifiers: Cmd, Ctrl, Opt.
  • On the Linux box, I use the same kinesis keyboard and have the same layout for the modifiers, such that I map:
Mac => Linux
CMD == Ctrl
Opt == Alt
Ctrl == Ctrl

The key was to have ctrl twice. And then I got used to the differences between cmd and ctrl on the mac, and on the PC, it worked out that ctrl is the key. For example:

In Chrome:

Ctrl-tab on the Mac ==> Ctrl-tab on Linux
Cmd-C on the Mac ==> Ctrl-c on Linux.

So I can hit two different keys on Linux and get the same result as the Mac.

If you have a windows type keyboard, you can remap something like the special windows key to be the mac command key.

I've since switched to just using a Mac, and, without a doubt, that's way more efficient for touch typing!

2
  • 2
    Good trick but it forces you to make Ubuntu act like Mac and not the opposite. Also this approach won't work with Gnome3 since CMD is used for the overview of windows and search (mission control + Alfred equivalents). What is "touch typing" btw?
    – Pithikos
    Jul 22, 2017 at 17:39
  • Pithikos do you have another keyboard configuration you prefer then for using a common keyboard on both ubuntu and mac, but to make the mac feel more like ubuntu?
    – Max Power
    Dec 6, 2018 at 3:53
2

Updated

Kinto.sh will now map Alt/Cmd to use Ctrl+Shift while in a terminal app. It of course maps Alt/Cmd to Ctrl the rest of the time.


Here's a much a simpler solution, Kinto. It tackles the very issue you're having with terminal keymaps not working right while keeping a good keymap with everything else.

I've been working on this for 3 years now.. and finally feel like I can contribute something back because of how well it works, unlike my last 2 attempts. It is intended for x11, and systemd based distros, but the concept will carry over to Wayland once I find a good way to implement it, despite the enhance security that makes it difficult to work with.

1) Gist (for those that just want to see the premise or implement their own alternating solution, edge cases not covered).

https://gist.github.com/rbreaves/f4cf8a991eaeea893999964f5e83eebb

2) The full on installer that makes use of systemd, bash, and xprop. (Edge cases, like chromebooks are covered, it was surprisingly difficult to support, but I enjoy mine so everyone can benefit!)

https://github.com/rbreaves/kinto

Essentially, with this solution you're not fighting how to properly create new shortcut keys or trying to avoid shortcut conflicts in your Terminal apps vs the rest of your GUI apps. You simply get the best of both words, and it works as seamlessly as it can - beyond including default shortcut config files for various terminals and popular text editors, which I may include later. Even text editors like Sublime don't simply swap out the Cmd key with Ctrl on every shortcut, but it aligns properly about 95% or more of the time I'd say.

And talking about Wayland I do have a proof of concept of how to make this keymap keyswap trick work on KDE Plasma 5 with an existing widget that pulls in app names. If anyone has a better solution then I am all ears, especially if it can work on x11 as well. Xprop is completely sufficient on x11, but obviously no use on Wayland.

https://github.com/rbreaves/applet-window-title/commit/ff17e694579a52a9848d6bea87b2d11f22033718

1

I went through this a while ago and found someones autokey setup (I would give credit if I could find where it came from).

I modified it for some things that were missing for my setup, but here it is:

https://github.com/ericwooley/dotfiles/tree/master/.config/autokey

It gets me to like 95% percent of all the keystrokes being the same.

Some things that are still different cmd + right and cmd + left don't act the same, on Linux I use alt+page-up and down.

I ended up depending on vim bindings in my editor to keep me sane, I would recommend that if it's possible for what you're doing.

Oh, and guake has a configurable copy and paste setting for the terminal, so I set that to be alt+c and alt+p for terminal shenanigans

1
0

KDE (Kubuntu) has a shortcut config tool that lets you set global shortcuts, but I couldn't get it to recognize the changes when I tested it. Perhaps it needs a restart. Maybe Ubuntu has a similar option.

Another thing that might help with the copy and paste functions in Linux is to use the middle mouse button to paste. When you highlight some text, you don't have to copy it - highlight it, switch to your other app, then click the middle mouse button to paste the highlighted text. Different habits would make the keyboard issue a moot point, at least for those specific functions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .