dotfiles/helix/gen_dvorak_config.sh

27 lines
4.6 KiB
Bash
Raw Normal View History

2023-09-27 14:37:16 -04:00
#!/bin/sh
exit 1
# run these manually need some fixup
# this will mostly generate the default config, you need to go through and put in [keys.normal.g] etc
curl -s https://raw.githubusercontent.com/helix-editor/helix/master/helix-term/src/keymap/default.rs | grep '" =>' | sed -re 's/ *(".*") => (.*),/\1 = "\2" # \1/' -e 's/^("[^"]*") [|] ("[^"]*")([^=]*)= (.*)/\1 = \4\n\2\3= \4/g' | sed -r 's/^("[^"]*") [|] ("[^"]*")([^=]*)= (.*)/\1 = \4\n\2\3= \4/g'
# keymap
# qwerty="qwertyuiop[]asdfghjkl;'zxcvbnm,./-=QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>?_+"
# dvorak="',.pyfgcrl/=aoeuidhtns-;qjkxbmwvz[]\"<>PYFGCRL?+AOEUIDHTNS_:QJKXBMWVZ{}"
# keymap removed single and double quotes
qwerty="wertyuiop[]asdfghjkl;zxcvbnm,./-=WERTYUIOP{}ASDFGHJKL:ZXCVBNM<>?_+"
dvorak=",.pyfgcrl/=aoeuidhtns;qjkxbmwvz[]<>PYFGCRL?+AOEUIDHTNS:QJKXBMWVZ{}"
# generate sed command:
for i in $(seq 0 $((${#qwerty} - 1))); do echo s@^\"[${qwerty:i:1}]\" = "(.*) # (\"[${qwerty:i:1}]\")"@\"${dvorak:i:1}\" = "\1 # \2"@; done | sed -e "s/^/-e '/" -e "s/$/'/" | tr '\n' ' '
# manual sed for single/double quotes
# q -> ', ' > -, Q > \", \" > _
# -e 's@^"[q]" = (.*) # ("[q]")@"'"'"'" = \1 # \2@' -e 's@^"['"'"']" = (.*) # ("['"'"']")@"minus" = \1 # \2@' -e 's@^"[Q]" = (.*) # ("[Q]")@"\\"" = \1 # \2@' -e 's@^"[\]["]" = (.*) # ("[\]["]")@"_" = \1 # \2@'
# output of above with single quotes added back in
sed -r -e 's@^"[q]" = (.*) # ("[q]")@"'"'"'" = \1 # \2@' -e 's@^"['"'"']" = (.*) # ("['"'"']")@"minus" = \1 # \2@' -e 's@^"[Q]" = (.*) # ("[Q]")@"\\"" = \1 # \2@' -e 's@^"[\]["]" = (.*) # ("[\]["]")@"_" = \1 # \2@' -e 's@^"[w]" = (.*) # ("[w]")@"," = \1 # \2@' -e 's@^"[e]" = (.*) # ("[e]")@"." = \1 # \2@' -e 's@^"[r]" = (.*) # ("[r]")@"p" = \1 # \2@' -e 's@^"[t]" = (.*) # ("[t]")@"y" = \1 # \2@' -e 's@^"[y]" = (.*) # ("[y]")@"f" = \1 # \2@' -e 's@^"[u]" = (.*) # ("[u]")@"g" = \1 # \2@' -e 's@^"[i]" = (.*) # ("[i]")@"c" = \1 # \2@' -e 's@^"[o]" = (.*) # ("[o]")@"r" = \1 # \2@' -e 's@^"[p]" = (.*) # ("[p]")@"l" = \1 # \2@' -e 's@^"[[]" = (.*) # ("[[]")@"/" = \1 # \2@' -e 's@^"[]]" = (.*) # ("[]]")@"=" = \1 # \2@' -e 's@^"[a]" = (.*) # ("[a]")@"a" = \1 # \2@' -e 's@^"[s]" = (.*) # ("[s]")@"o" = \1 # \2@' -e 's@^"[d]" = (.*) # ("[d]")@"e" = \1 # \2@' -e 's@^"[f]" = (.*) # ("[f]")@"u" = \1 # \2@' -e 's@^"[g]" = (.*) # ("[g]")@"i" = \1 # \2@' -e 's@^"[h]" = (.*) # ("[h]")@"d" = \1 # \2@' -e 's@^"[j]" = (.*) # ("[j]")@"h" = \1 # \2@' -e 's@^"[k]" = (.*) # ("[k]")@"t" = \1 # \2@' -e 's@^"[l]" = (.*) # ("[l]")@"n" = \1 # \2@' -e 's@^"[;]" = (.*) # ("[;]")@"s" = \1 # \2@' -e 's@^"[z]" = (.*) # ("[z]")@";" = \1 # \2@' -e 's@^"[x]" = (.*) # ("[x]")@"q" = \1 # \2@' -e 's@^"[c]" = (.*) # ("[c]")@"j" = \1 # \2@' -e 's@^"[v]" = (.*) # ("[v]")@"k" = \1 # \2@' -e 's@^"[b]" = (.*) # ("[b]")@"x" = \1 # \2@' -e 's@^"[n]" = (.*) # ("[n]")@"b" = \1 # \2@' -e 's@^"[m]" = (.*) # ("[m]")@"m" = \1 # \2@' -e 's@^"[,]" = (.*) # ("[,]")@"w" = \1 # \2@' -e 's@^"[.]" = (.*) # ("[.]")@"v" = \1 # \2@' -e 's@^"[/]" = (.*) # ("[/]")@"z" = \1 # \2@' -e 's@^"[-]" = (.*) # ("[-]")@"[" = \1 # \2@' -e 's@^"[=]" = (.*) # ("[=]")@"]" = \1 # \2@' -e 's@^"[W]" = (.*) # ("[W]")@"<" = \1 # \2@' -e 's@^"[E]" = (.*) # ("[E]")@">" = \1 # \2@' -e 's@^"[R]" = (.*) # ("[R]")@"P" = \1 # \2@' -e 's@^"[T]" = (.*) # ("[T]")@"Y" = \1 # \2@' -e 's@^"[Y]" = (.*) # ("[Y]")@"F" = \1 # \2@' -e 's@^"[U]" = (.*) # ("[U]")@"G" = \1 # \2@' -e 's@^"[I]" = (.*) # ("[I]")@"C" = \1 # \2@' -e 's@^"[O]" = (.*) # ("[O]")@"R" = \1 # \2@' -e 's@^"[P]" = (.*) # ("[P]")@"L" = \1 # \2@' -e 's@^"[{]" = (.*) # ("[{]")@"?" = \1 # \2@' -e 's@^"[}]" = (.*) # ("[}]")@"+" = \1 # \2@' -e 's@^"[A]" = (.*) # ("[A]")@"A" = \1 # \2@' -e 's@^"[S]" = (.*) # ("[S]")@"O" = \1 # \2@' -e 's@^"[D]" = (.*) # ("[D]")@"E" = \1 # \2@' -e 's@^"[F]" = (.*) # ("[F]")@"U" = \1 # \2@' -e 's@^"[G]" = (.*) # ("[G]")@"I" = \1 # \2@' -e 's@^"[H]" = (.*) # ("[H]")@"D" = \1 # \2@' -e 's@^"[J]" = (.*) # ("[J]")@"H" = \1 # \2@' -e 's@^"[K]" = (.*) # ("[K]")@"T" = \1 # \2@' -e 's@^"[L]" = (.*) # ("[L]")@"N" = \1 # \2@' -e 's@^"[:]" = (.*) # ("[:]")@"S" = \1 # \2@' -e 's@^"[Z]" = (.*) # ("[Z]")@":" = \1 # \2@' -e 's@^"[X]" = (.*) # ("[X]")@"Q" = \1 # \2@' -e 's@^"[C]" = (.*) # ("[C]")@"J" = \1 # \2@' -e 's@^"[V]" = (.*) # ("[V]")@"K" = \1 # \2@' -e 's@^"[B]" = (.*) # ("[B]")@"X" = \1 # \2@' -e 's@^"[N]" = (.*) # ("[N]")@"B" = \1 # \2@' -e 's@^"[M]" = (.*) # ("[M]")@"M" = \1 # \2@' -e 's@^"[<]" = (.*) # ("[<]")@"W" = \1 # \2@' -e 's@^"[>]" = (.*) # ("[>]")@"V" = \1 # \2@' -e 's@^"[?]" = (.*) # ("[?]")@"Z" = \1 # \2@' -e 's@^"[_]" = (.*) # ("[_]")@"{" = \1 # \2@' -e 's@^"[+]" = (.*) # ("[+]")@"}" = \1 # \2@' config.orig.toml > config.dvorak.toml