Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save denlab/953372 to your computer and use it in GitHub Desktop.
Save denlab/953372 to your computer and use it in GitHub Desktop.
Keyboard remapping for easier Emacs
# ------------------------------------------------------------------------------
# A few key remapping on GNU/Linux, for easier Emacs.
#
# Note: You need a querty keyboard in the first place because it removes the alt-gr key.
#
# Replace :
# - capslock by ctrl
# - altgr by alt
#
# To have an alt on the right and an easier ctrl on the left.
# For a much better Emacs experience.
# ------------------------------------------------------------------------------
if [[ $(xmodmap) == *ISO_Level3_Shift* ]]
then
echo "xmodmap not customized !";
# ------------------------------------------------------------------------------
# Keyboard customization : replace caps lock by control
# ------------------------------------------------------------------------------
echo " replacing capsLocks by control ....";
xmodmap -e 'remove Lock = Caps_Lock'
xmodmap -e 'keysym Caps_Lock = Control_L'
xmodmap -e 'add Control = Control_L'
# ------------------------------------------------------------------------------
# Keyboard customization : replace altgr by alt
# ------------------------------------------------------------------------------
echo " replacing altgr by leftAlt ....";
xmodmap -e 'clear mod5'
xmodmap -e 'add mod1 = Mode_switch'
xmodmap -e "keysym ISO_Level3_Shift = Alt_L"
else
echo "xmodmap already customized !";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment