zsh-config/keyboard
Robert Morrison 2ad568db03
feat(keyboard): Use paste and quote magic
Use both bracketed-paste-magic and url-quote-magic to make pasting urls
into the terminal a little nicer.
NOTE: In rare cases this can break things, and will slow down pasting.
2024-02-19 15:12:31 +00:00

31 lines
1.3 KiB
Bash

## Use zkbd to set automagical keybinkds
## this can fix terminals that have different outputs for keys than expoected
autoload -Uz zkbd
if [[ -f $ZDOTDIR/.zkbd/$TERM-${DISPLAY:-$VENDOR-$OSTYPE} ]]; then
source $ZDOTDIR/.zkbd/$TERM-${DISPLAY:-$VENDOR-$OSTYPE}
else
echo "No mappings for $TERM-${DISPLAY:-$VENDOR-$OSTYPE}"
echo "WARNING: Keybindings may not be set correctly!"
echo "Execute \`zkbd\` to create bindings."
fi
zle -N history-beginning-search-backward-end \
history-search-end
zle -N history-beginning-search-forward-end \
history-search-end
zle -N bracketed-paste bracketed-paste-magic
zle -N self-insert url-quote-magic
[[ -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[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
[[ -n "${key[Backspace]}" ]] && bindkey "${key[Backspace]}" backward-delete-char
[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-search
[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-search
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
## vim: ft=zsh