Skip to content

Instantly share code, notes, and snippets.

@hallettj
Last active May 7, 2024 03:04
Show Gist options
  • Save hallettj/9735209 to your computer and use it in GitHub Desktop.
Save hallettj/9735209 to your computer and use it in GitHub Desktop.
I inverted the number row on my keyboard - meaning that pressing the keys produces symbols by default, and I type numbers by holding shift. As a programmer I use symbols frequently, so I think that this will be advantageous. Here are the details of my configuration.
!
! Invert number row
!
! This changes the behavior of keys in the number row, but does not
! affect the number pad.
!
keycode 10 = exclam 1 1 exclam
keycode 11 = at 2 2 at
keycode 12 = numbersign 3 3 numbersign
keycode 13 = dollar 4 4 dollar
keycode 14 = percent 5 5 percent
keycode 15 = asciicircum 6 6 asciicircum dead_circumflex dead_circumflex dead_circumflex
keycode 16 = ampersand 7 7 ampersand
keycode 17 = asterisk 8 8 asterisk
keycode 18 = parenleft 9 9 parenleft dead_grave NoSymbol dead_grave
keycode 19 = parenright 0 0 parenright
!
! Normal number row
!
! Comment the above block and uncomment this one to return to the
! original number row behavior.
!
! keycode 10 = 1 exclam 1 exclam
! keycode 11 = 2 at 2 at
! keycode 12 = 3 numbersign 3 numbersign
! keycode 13 = 4 dollar 4 dollar
! keycode 14 = 5 percent 5 percent
! keycode 15 = 6 asciicircum 6 asciicircum dead_circumflex dead_circumflex dead_circumflex
! keycode 16 = 7 ampersand 7 ampersand
! keycode 17 = 8 asterisk 8 asterisk
! keycode 18 = 9 parenleft 9 parenleft dead_grave NoSymbol dead_grave
! keycode 19 = 0 parenright 0 parenright
! These mappings are based on the defaults for my keyboard layout. You
! can get the default mappings for your keyboard with the command:
!
! xmodmap -pke
!
! I recommend saving the output in a file for reference.
!
! Bonus: change Caps_Lock to Control_L and change the original Control_L
! to Hyper_L
!
clear lock
clear control
clear mod1
clear mod2
clear mod3
clear mod4
clear mod5
keycode 66 = Control_L
keycode 37 = Hyper_L
add control = Control_L Control_R
add mod1 = Alt_L Alt_R Meta_L
add mod2 = Num_Lock
add mod3 = Hyper_L
add mod4 = Super_L Super_R
add mod5 = Mode_switch ISO_Level3_Shift
-- Excerpts from my xmonad configuration:
-- *snip* --
import XMonad
import qualified Data.Map as M
-- *snip* --
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
-- I wanted to continue using the same shortcuts to change workspaces
-- in xmonad with an inverted number row. So I created additional
-- shortcuts based on symbols.
--
-- For example, this makes Alt-@ do the some thing that Alt-2 does.
-- It does the same for Alt-Shift-@ and Alt-Shift-2.
[((m .|. modMask, k), windows $ f i)
| (i, k) <- zip (XMonad.workspaces conf) symbols
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
++
-- This defines the default shortcuts for changing workspaces:
--
-- mod-[1..9], Switch to workspace N
-- mod-shift-[1..9], Move client to workspace N
[((m .|. modMask, k), windows $ f i)
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
where
symbols :: [KeySym]
symbols = [ xK_exclam
, xK_at
, xK_numbersign
, xK_dollar
, xK_percent
, xK_asciicircum
, xK_ampersand
, xK_asterisk
, xK_parenleft
, xK_parenright ]
-- It is important that the symbols above are listed in the same order
-- that they appear on my number row.
-- You can find the full list of key identifiers in:
-- http://xmonad.org/xmonad-docs/X11/src/Graphics-X11-Types.html
-- *snip* --
main = do
-- *snip* --
xmonad $ defaultConfig {
-- *snip* --
keys = \c -> myKeys c `M.union` myOtherKeys c
-- *snip* --
}
-- My full configuration is available at:
-- https://github.com/hallettj/dot-xmonad/blob/master/home/.xmonad/xmonad.hs
# Excerpts from my tmux configuration:
# I wanted to continue to use the same shortcuts for changing windows in
# tmux with the inverted number row. So I created additional shortcuts
# that mimic the behavior of the number-based shortcuts:
bind ')' select-window -t :0
bind '!' select-window -t :1
bind '@' select-window -t :2
bind '#' select-window -t :3
bind '$' select-window -t :4
bind '%' select-window -t :5
bind '^' select-window -t :6
bind '&' select-window -t :7
bind '*' select-window -t :8
bind '(' select-window -t :9
# I use vi keys, and I often use 0 to jump to the beginning of a line in
# copy mode. With this extra shortcut I can continue to do so without
# having to hold Shift.
bind-key -t vi-copy ')' start-of-line
# My full configuration is available at:
# https://github.com/hallettj/dot-files/blob/master/home/.tmux.conf
" Excerpts from my Vim configuration:
" I often use 0 to jump to the beginning of a line. With mapping I can
" continue to use the same shortcut with an inverted number row.
nnoremap ) 0
" By default Vim binds ) to a movement that goes forward a sentence at
" a time. I don't really use that movement. But if I want to start
" I might set up these mappings to preserve the original bindings:
nnoremap 0 )
nnoremap 9 (
" By using `nnoremap` instead of `nmap` I can swap keys like that
" without getting into an infinite loop.
" My full configuration is available at:
" https://github.com/hallettj/dot-vim/blob/master/home/.vimrc
# Excerpts from my Zsh configuration:
# As with Vim, I often use 0 to jump to the beginning of a line in Zsh,
# and I want to use the same shortcut with the inverted number row.
bindkey -a ')' vi-digit-or-beginning-of-line
# My full configuration is available at:
# https://github.com/hallettj/dot-zsh/blob/master/home/.zshrc
# https://github.com/hallettj/dot-zsh/blob/master/home/.config/zsh.d/60-key-bindings
# Excerpts from my irssi configuration:
keyboard = (
# Alternative shortcuts for changing windows that work well with
# inverted number row.
{ key = "meta-!"; id = "change_window"; data = "1"; },
{ key = "meta-@"; id = "change_window"; data = "2"; },
{ key = "meta-#"; id = "change_window"; data = "3"; },
{ key = "meta-$"; id = "change_window"; data = "4"; },
{ key = "meta-%"; id = "change_window"; data = "5"; },
{ key = "meta-^"; id = "change_window"; data = "6"; },
{ key = "meta-&"; id = "change_window"; data = "7"; },
{ key = "meta-*"; id = "change_window"; data = "8"; },
{ key = "meta-("; id = "change_window"; data = "9"; },
# I rebind the default window-changing shortcuts second so that the
# titles in my window list continue to be labeled with numbers.
# Without this part my windows are labeled with symbols instead.
{ key = "meta-1"; id = "change_window"; data = "1"; },
{ key = "meta-2"; id = "change_window"; data = "2"; },
{ key = "meta-3"; id = "change_window"; data = "3"; },
{ key = "meta-4"; id = "change_window"; data = "4"; },
{ key = "meta-5"; id = "change_window"; data = "5"; },
{ key = "meta-6"; id = "change_window"; data = "6"; },
{ key = "meta-7"; id = "change_window"; data = "7"; },
{ key = "meta-8"; id = "change_window"; data = "8"; },
{ key = "meta-9"; id = "change_window"; data = "9"; }
);
# My full configuration is available at:
# https://github.com/hallettj/dot-files/blob/master/home/.irssi/config
# Excerpts from my Readline configuration. For information about
# Readline see:
# http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
set editing-mode vi
set blink-matching-paren on
$if mode=vi
set keymap vi-command
")": beginning-of-line # As with Vim and Zsh, I use 0 to jump to the start of lines.
set keymap vi-insert
# Insert-mode bindings go here.
$endif
# My full configuration is available at:
# https://github.com/hallettj/dot-zsh/blob/master/home/.inputrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment