diff options
author | mia <mia@mia.jetzt> | 2024-03-10 13:28:56 -0700 |
---|---|---|
committer | mia <mia@mia.jetzt> | 2024-03-10 13:28:56 -0700 |
commit | efe49395d4194db30f55a91503c91cda33530e8e (patch) | |
tree | c2f73587f40d4cd9d66c906fbfcfda97620074cc /zsh/init-keymap.zsh | |
parent | 762534242de9e84a4bceb45a1ca2e58d2a15b50d (diff) | |
download | dotfiles-efe49395d4194db30f55a91503c91cda33530e8e.tar.gz dotfiles-efe49395d4194db30f55a91503c91cda33530e8e.zip |
add zsh configuration
Diffstat (limited to 'zsh/init-keymap.zsh')
-rwxr-xr-x | zsh/init-keymap.zsh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/zsh/init-keymap.zsh b/zsh/init-keymap.zsh new file mode 100755 index 0000000..b3c3c90 --- /dev/null +++ b/zsh/init-keymap.zsh @@ -0,0 +1,53 @@ +#!/bin/zsh + +keymap_file="$1" + +# taken from zkbd +emulate -RL zsh +trap "return 1" 1 2 15 +function getseq() { + trap "stty ${$(stty -g 2>/dev/null):-echo -raw}" 0 1 2 15 + stty raw -echo + local k='' seq='' i + for ((i=10; i>0; --i)) + do + read -t -k 1 k && break + sleep 1 + done + [[ -n $k ]] || exit + [[ $k = $'\012' || $k = $'\015' || $k = ' ' ]] && exit + seq=$k + while read -t -k 1 k + do + seq=$seq$k + done + print -Rn ${(V)seq} +} + +function entry() { + echo -n "$1: " + seq="$(getseq)" + echo + echo "key[$1]='$seq'" >> "$keymap_file.tmp" +} + +echo "keymap time!" +echo 'typeset -g -A key' > "$keymap_file.tmp" +entry Backspace +entry CtrlBackspace +entry Insert +entry Delete +entry PageUp +entry PageDown +entry Home +entry End +entry Up +entry Left +entry Down +entry Right +entry CtrlUp +entry CtrlLeft +entry CtrlDown +entry CtrlRight + +mv "$keymap_file.tmp" "$keymap_file" |