Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I followed xmodmap way of swapping ESC and Caps lock in this link. It works well when I load .bashrc with . ~/.bashrc for the first time. However, if I edit different part of my .bashrc and reload it with same command, two keys are swapped back to original mapping. Why is this happening?

Portion of my .bashrc file

xmodmap ~/.speedswapper

My ~/.speedswapper script

remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock
share|improve this question

migrated from Apr 11 '13 at 17:27

This question came from our site for professional and enthusiast programmers.

up vote 2 down vote accepted

This happens because ~/.bashrc is called every time you open a new terminal. You should put xmodmap ~/.speedswapper to some file that is executed once you log into your machine. I prefer to have it present in ~/.xinitrc

A better way would be to put the swap code under ~/.Xmodmap which is executed correctly. But it has always been flaky to me.

share|improve this answer
Thanks a lot! I placed the codes in ~/.Xmodmap, and it's working like charm. I still don't get why .bashrc getting loaded twice resets the swap...I'm fairly new to bash... – kidonchu Apr 11 '13 at 13:58
@kidonchu Because that code is executed on second load as well. If you load .bashrc again, it'll swap those keys again. Try loading it three times. – Waseem Apr 11 '13 at 16:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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