Category: articles


Make Apple CMD/Command key an additional CTRL/Control key in X11

February 5th, 2014 — 10:03 pm

If you want to use shortcuts in Linux/X11 as you are used to in OSX, you can configure X11 to use the CMD key as an additional CTRL key. Your muscle memory of CMD+c, CMD+s, CMD+v will not betray you anymore, then.

Since Linux is highly configurable, we can just tamper with the keymap.

1. Create a file ~/.Xmodmap

! clear CMD of it's regular task, whatever that might be
clear mod4

! configure CTRL and CMD to act as left Control
keycode 133 = Control_L NoSymbol Control_L
keycode 37 = Control_L NoSymbol Control_L

! use CTRL and CMD to act as left Control
add control = Control_L

Note: This works for my Macbook Pro (early 2011) with US layout. Your machine may use different keycodes. You can find out easily which is your CMD key, though. Just look for “Super_L” in your current keymap.

➜  ~  xmodmap -pke | grep Super_L
keycode 133 = Super_L NoSymbol Super_L

2. Load keymap patch

xmodmap ~/.Xmodmap

3. Autoloading

When this works for you (try copy/pasting/saving), then make sure to autoload .Xmodmap on start of X11. I do that using my window manager I3, but you also might add something similar to .xinitrc or .xsession

echo "exec xmodmap ~/.Xmodmap &" >> .i3/config

Comment » | articles

My Github username changed from ‘preek’ to ‘munen’

March 9th, 2013 — 01:43 pm

If you have cloned one of my repositories, the ‘remote origin’ will now point to a 404. For your convenience I have written a script to easily change your checkout.

If you want to use it, please use your terminal to go to the checked out repository and enter the following command:

curl https://gist.github.com/munen/5124033/raw/4e38d1eb1d0e6965a4b031e48e2284d0df15eaab/hange_remote_origin.sh | sh

This will produce output like this:

$ cd ~src/the_tale_of_genji

$ curl https://gist.github.com/munen/5124033/raw/4e38d1eb1d0e6965a4b031e48e2284d0df15eaab/hange_remote_origin.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   375    0   375    0     0    374      0 --:--:--  0:00:01 --:--:--   465
Showing old remote origin
origin	git@github.com:preek/the_tale_of_genji.git (fetch)
origin	git@github.com:preek/the_tale_of_genji.git (push)
--------
succeeded in setting new remote
--------
Showing new remote origin
origin	git@github.com:munen/the_tale_of_genji.git (fetch)
origin	git@github.com:munen/the_tale_of_genji.git (push)

Comment » | articles, personal

Just released a new gem for Rails called “is_association?” https://rubygems.org/gems/is_association

November 5th, 2012 — 11:54 am

The gem patches ActiveRecord::Base to expose a method is_association? The method will return true for associations like has_one, has_many and belongs_to while returning false for regular attributes on the table.

Comment » | articles

« Previous Entries     Next Entries »