diff --git a/zsh/.zkbd/xterm-256color-:1 b/zsh/.zkbd/xterm-256color-:1 new file mode 100644 index 0000000..f9e4eea --- /dev/null +++ b/zsh/.zkbd/xterm-256color-:1 @@ -0,0 +1,26 @@ +typeset -g -A key + +key[F1]='^[OP' +key[F2]='^[OQ' +key[F3]='^[OR' +key[F4]='^[OS' +key[F5]='^[[15~' +key[F6]='^[[17~' +key[F7]='^[[18~' +key[F8]='^[[19~' +key[F9]='^[[20~' +key[F10]='''' +key[F11]='''' +key[F12]='^[[24~' +key[Backspace]='^?' +key[Insert]='^[[2~' +key[Home]='^[[H' +key[PageUp]='^[[5~' +key[Delete]='^[[3~' +key[End]='^[[F' +key[PageDown]='^[[6~' +key[Up]='^[[A' +key[Left]='^[[D' +key[Down]='^[[B' +key[Right]='^[[C' +key[Menu]='''' diff --git a/zsh/.zshrc b/zsh/.zshrc index acce7c9..9ca693b 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -8,6 +8,26 @@ if [[ -o interactive ]] && [[ -n $SSH_TTY ]] && [[ -z $TMUX ]] && hash tmux &> / exit $? fi +####################### +# Initialize keyboard # +####################### + +autoload zkbd +function zkbd_file() { + [[ -f ~/.zkbd/${TERM}-${VENDOR}-${OSTYPE} ]] && printf '%s' ~/".zkbd/${TERM}-${VENDOR}-${OSTYPE}" && return 0 + [[ -f ~/.zkbd/${TERM}-${DISPLAY} ]] && printf '%s' ~/".zkbd/${TERM}-${DISPLAY}" && return 0 + return 1 +} + +[[ ! -d ~/.zkbd ]] && mkdir ~/.zkbd +keyfile=$(zkbd_file) +if [[ $? -eq 0 ]]; then + source "${keyfile}" +elif [[ -o interactive ]]; then + echo "Unable to load key data for special keys. Run zkbd to fix." +fi +unfunction zkbd_file; unset keyfile + bindkey -e # zshrc aliases alias ls='ls --color=auto' @@ -68,8 +88,8 @@ if [[ -f /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting. fi # Home and end keys working -bindkey "${terminfo[khome]}" beginning-of-line -bindkey "${terminfo[kend]}" end-of-line +bindkey "${key[Home]}" beginning-of-line +bindkey "${key[End]}" end-of-line # Transfer.sh plugin transfer() { if [ $# -eq 0 ]; then echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi