Skip to content

Instantly share code, notes, and snippets.

@dixler
Last active October 15, 2017 04:49
Show Gist options
  • Save dixler/c843e90789fce0535ac2c7b1577167d0 to your computer and use it in GitHub Desktop.
Save dixler/c843e90789fce0535ac2c7b1577167d0 to your computer and use it in GitHub Desktop.
Tmux: Keyboard layout swap
################################################################################
# Dvorak to Qwerty
################################################################################
# Lowercase maps
unbind -n q
unbind -n w
unbind -n e
unbind -n r
unbind -n t
unbind -n y
unbind -n u
unbind -n i
unbind -n o
unbind -n p
unbind -n [
unbind -n ]
unbind -n a
unbind -n s
unbind -n d
unbind -n f
unbind -n g
unbind -n h
unbind -n j
unbind -n k
unbind -n l
unbind -n \;
unbind -n "'"
unbind -n z
unbind -n x
unbind -n c
unbind -n v
unbind -n b
unbind -n n
unbind -n m
unbind -n ,
unbind -n .
unbind -n /
unbind -n -
unbind -n =
# Uppercase maps
unbind -n Q
unbind -n W
unbind -n E
unbind -n R
unbind -n T
unbind -n Y
unbind -n U
unbind -n I
unbind -n O
unbind -n P
unbind -n }
unbind -n {
unbind -n A
unbind -n S
unbind -n D
unbind -n F
unbind -n G
unbind -n H
unbind -n J
unbind -n K
unbind -n L
unbind -n :
unbind -n '"'
unbind -n Z
unbind -n X
unbind -n C
unbind -n V
unbind -n B
unbind -n N
unbind -n M
unbind -n <
unbind -n >
unbind -n ?
unbind -n _
unbind -n +
# Control maps
#unbind -n C-q # dne
#unbind -n C-w # dne
#unbind -n C-e # dne
unbind -n C-r
unbind -n C-t
unbind -n C-y
unbind -n C-u
unbind -n C-i
unbind -n C-o
unbind -n C-p
#unbind -n C-[ # don't reunbind escape
#unbind -n C-] # dne
unbind -n C-a
unbind -n C-s
unbind -n C-d
unbind -n C-f
unbind -n C-g
unbind -n C-h
unbind -n C-j
unbind -n C-k
unbind -n C-l
#unbind -n C-; # dne
#unbind -n C-' # dne
#unbind -n C-z # dne
unbind -n C-x
unbind -n C-c
unbind -n C-v
unbind -n C-b
unbind -n C-n
unbind -n C-m
#unbind -n C-, # dne
#unbind -n C-. # dne
unbind -n C-_
#unbind -n C-- # dne
#unbind -n C-= # dne
################################################################################
# Qwerty to Dvorak
################################################################################
# Prefix
set -g prefix C-_ # C-/ is the same as C-_
bind / send-prefix
bind C-_ last-window
# Lowercase maps
# QWERTY DVORAK
bind -n q send "'"
bind -n w send ,
bind -n e send .
bind -n r send p
bind -n t send y
bind -n y send f
bind -n u send g
bind -n i send c
bind -n o send r
bind -n p send l
bind -n [ send /
bind -n ] send =
bind -n a send a
bind -n s send o
bind -n d send e
bind -n f send u
bind -n g send i
bind -n h send d
bind -n j send h
bind -n k send t
bind -n l send n
bind -n \; send s
bind -n "'" send -
bind -n z send \\;
bind -n x send q
bind -n c send j
bind -n v send k
bind -n b send x
bind -n n send b
bind -n m send m
bind -n , send w
bind -n . send v
bind -n / send z
bind -n - send [
bind -n = send ]
# Uppercase maps
# QWERTY DVORAK
bind -n Q send '"'
bind -n W send <
bind -n E send >
bind -n R send P
bind -n T send Y
bind -n Y send F
bind -n U send G
bind -n I send C
bind -n O send R
bind -n P send L
bind -n } send ?
bind -n { send =
bind -n A send A
bind -n S send O
bind -n D send E
bind -n F send U
bind -n G send I
bind -n H send D
bind -n J send H
bind -n K send T
bind -n L send N
bind -n : send S
bind -n '"' send _
bind -n Z send :
bind -n X send Q
bind -n C send J
bind -n V send K
bind -n B send X
bind -n N send B
bind -n M send M
bind -n < send W
bind -n > send V
bind -n ? send Z
bind -n _ send {
bind -n + send }
# Control maps
# QWERTY DVORAK
#bind -n C-q send C-' # dne
#bind -n C-w send C-, # dne
#bind -n C-e send C-. # dne
bind -n C-r send C-p
bind -n C-t send C-y
bind -n C-y send C-f
bind -n C-u send C-g
bind -n C-i send C-c
bind -n C-o send C-r
bind -n C-p send C-l
#bind -n C-[ send C-_ # don't rebind escape
#bind -n C-] send C-= # dne
bind -n C-a send C-a
bind -n C-s send C-o
bind -n C-d send C-e
bind -n C-f send C-u
bind -n C-g send C-i
bind -n C-h send C-d
bind -n C-j send C-h
bind -n C-k send C-t
bind -n C-l send C-n
#bind -n C-; send C-s # dne
#bind -n C-' send C-- # dne
#bind -n C-z send C-; # dne
bind -n C-x send C-q
bind -n C-c send C-j
bind -n C-v send C-k
bind -n C-b send C-x
bind -n C-n send C-b
bind -n C-m send C-m
#bind -n C-, send C-w # dne
#bind -n C-. send C-v # dne
bind -n C-_ send C-z
#bind -n C-- send C-[ # dne
#bind -n C-= send C-] # dne
set -g status-right '"#22T" %H:%M %d-%b-%y [D]'
unbind C-b
set -g prefix C-z
bind z send-prefix
bind C-z last-window
# Keyboard layout change
bind -n F10 source-file ~/.tmux-qwerty2dv.conf\; set -gq status-right '"#22T" %H:%M %d-%b-%y [Q]'
bind -n F9 source-file ~/.tmux-dv2qwerty.conf\; source-file ~/.tmux.conf
Sometimes I need to access my tmux session from a foreign box. Nearly all the
time this box is has a Qwerty keyboard layout. Being a Dvorak user, this makes
my life difficult.
I could dig around the OS settings and switch it, but that takes time and also
leaves the possibility that I forget to switch it back, which makes life
difficult for others.
Instead, I have opted to create a set of configuration files to have tmux do
the layout remapping for me. It isn't perfect, but it works well enough for my
needs. I don't plan on doing any serious code editing outside of my
environment, but if I need to review some debug or copy a few files somewhere,
it's nice to be able to do it in my native layout.
All remapping is done in the qwerty2dv and dv2qwerty files.
qwerty2dv make tmux interpret qwerty keyboard sequences into dvorak ones
dv2qwerty is a poorly named, but it just reverts everything qwerty2dv does
In the main tmux config, I have these files source on F9 and F10. I also have
the toolbar change, so I always know what mode I'm in.
The quality of the remapping is pretty good. For normal keystrokes, the map is
1:1. Adding control characters, things don't pan out as well. This isn't a
limitation of tmux, but of the terminal. Some keys don't have control
sequences, for example ",". In Dvorak-land, that is Control-V, which is pretty
unfortunate because that is a pretty useful sequence to miss. Another one is
"=", which in Dvorak is "Control-]", the default mapping for traversing a tag
list in vim.
It's not perfect, but work well enough.
UPDATE:
fixed semicolon binding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment