diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | zsh/init-keymap.zsh | 53 | ||||
-rw-r--r-- | zsh/keymap/xterm-256color | 17 | ||||
-rw-r--r-- | zshrc | 39 |
4 files changed, 110 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4556bda --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/zsh/machine.zsh 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" diff --git a/zsh/keymap/xterm-256color b/zsh/keymap/xterm-256color new file mode 100644 index 0000000..47207d8 --- /dev/null +++ b/zsh/keymap/xterm-256color @@ -0,0 +1,17 @@ +typeset -g -A key +key[Backspace]='^?' +key[CtrlBackspace]='^H' +key[Insert]='^[[2~' +key[Delete]='^[[3~' +key[Home]='^[[H' +key[End]='^[[F' +key[PageUp]='^[[5~' +key[PageDown]='^[[6~' +key[Up]='^[[A' +key[Left]='^[[D' +key[Down]='^[[B' +key[Right]='^[[C' +key[CtrlUp]='^[[1;5A' +key[CtrlDown]='^[[1;5B' +key[CtrlRight]='^[[1;5C' +key[CtrlLeft]='^[[1;5D' diff --git a/zshrc b/zshrc new file mode 100644 index 0000000..fa6d882 --- /dev/null +++ b/zshrc @@ -0,0 +1,39 @@ +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +zstyle :compinstall filename '/home/.zshrc' +zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' +autoload -Uz compinit +compinit + +keymap_file="$HOME/.config/zsh/keymap/$TERM" +[[ ! -d "$(dirname "$keymap_file")" ]] && mkdir -p "$(dirname "$keymap_file")" +[[ ! -f "$keymap_file" ]] && ~/.config/zsh/init-keymap.zsh "$keymap_file" +source "$keymap_file" +unset keymap_file + +[[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line +[[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line +[[ -n "${key[Insert]}" ]] && bindkey -- "${key[Insert]}" overwrite-mode +[[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char +[[ -n "${key[CtrlBackspace]}" ]] && bindkey -- "${key[CtrlBackspace]}" backward-delete-word +[[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char +[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-history +[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-history +[[ -n "${key[Left]}" ]] && bindkey -- "${key[Left]}" backward-char +[[ -n "${key[Right]}" ]] && bindkey -- "${key[Right]}" forward-char +[[ -n "${key[CtrlLeft]}" ]] && bindkey -- "${key[CtrlLeft]}" backward-word +[[ -n "${key[CtrlRight]}" ]] && bindkey -- "${key[CtrlRight]}" forward-word + +export EDITOR=nano +export PAGER=less +alias zm=zmachine +alias zmachine="$EDITOR ~/.config/zsh/machine.zsh" +alias zshrc="$EDITOR ~/.zshrc" + +[[ -f ~/.config/zsh/machine.zsh ]] && source ~/.config/zsh/machine.zsh + +source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh +source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh +source <(starship init zsh) +source <(zoxide init zsh) |