|
|
@ -1,9 +1,15 @@ |
|
|
|
#!/bin/zsh |
|
|
|
#!/bin/zsh |
|
|
|
# ~/.zshrc |
|
|
|
# ~/.zshrc |
|
|
|
|
|
|
|
# |
|
|
|
|
|
|
|
# This file is sourced only for interactive shells. |
|
|
|
|
|
|
|
# |
|
|
|
|
|
|
|
# Global Order: zshenv, zprofile, zshrc, zlogin |
|
|
|
|
|
|
|
# |
|
|
|
# See: |
|
|
|
# See: |
|
|
|
# - https://zsh.sourceforge.io/Doc/Release/ |
|
|
|
# - https://zsh.sourceforge.io/Doc/Release/ |
|
|
|
# - https://stevenvanbael.com/profiling-zsh-startup |
|
|
|
# - https://stevenvanbael.com/profiling-zsh-startup |
|
|
|
# - https://zsh.sourceforge.io/Doc/Release/Options.html |
|
|
|
# - https://zsh.sourceforge.io/Doc/Release/Options.html |
|
|
|
|
|
|
|
# - https://salsa.debian.org/debian/zsh/-/blob/debian/debian/zshrc |
|
|
|
|
|
|
|
|
|
|
|
### History |
|
|
|
### History |
|
|
|
HISTFILE="$HOME/.zsh_history" |
|
|
|
HISTFILE="$HOME/.zsh_history" |
|
|
@ -31,8 +37,8 @@ alias history='history 1' # Print whole history |
|
|
|
# https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/key-bindings.zsh |
|
|
|
# https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/key-bindings.zsh |
|
|
|
# /etc/zsh/zshrc |
|
|
|
# /etc/zsh/zshrc |
|
|
|
|
|
|
|
|
|
|
|
# Use emacs key bindings |
|
|
|
# Use emacs key bindings by default |
|
|
|
bindkey -e |
|
|
|
bindkey ${KEYMAP:--e} |
|
|
|
|
|
|
|
|
|
|
|
# Make sure that the terminal is in application mode when zle is active, since |
|
|
|
# Make sure that the terminal is in application mode when zle is active, since |
|
|
|
# only then values from $terminfo are valid |
|
|
|
# only then values from $terminfo are valid |
|
|
@ -50,30 +56,72 @@ if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then |
|
|
|
|
|
|
|
|
|
|
|
# List of keys |
|
|
|
# List of keys |
|
|
|
key=( |
|
|
|
key=( |
|
|
|
|
|
|
|
BackSpace "${terminfo[kbs]}" |
|
|
|
|
|
|
|
Home "${terminfo[khome]}" |
|
|
|
|
|
|
|
End "${terminfo[kend]}" |
|
|
|
|
|
|
|
Insert "${terminfo[kich1]}" |
|
|
|
|
|
|
|
Delete "${terminfo[kdch1]}" |
|
|
|
Up "${terminfo[kcuu1]}" |
|
|
|
Up "${terminfo[kcuu1]}" |
|
|
|
Down "${terminfo[kcud1]}" |
|
|
|
Down "${terminfo[kcud1]}" |
|
|
|
|
|
|
|
Left "${terminfo[kcub1]}" |
|
|
|
|
|
|
|
Right "${terminfo[kcuf1]}" |
|
|
|
PageUp "${terminfo[kpp]}" |
|
|
|
PageUp "${terminfo[kpp]}" |
|
|
|
PageDown "${terminfo[knp]}" |
|
|
|
PageDown "${terminfo[knp]}" |
|
|
|
) |
|
|
|
) |
|
|
|
else |
|
|
|
|
|
|
|
# Fallback to manually managed user-driven database |
|
|
|
|
|
|
|
printf 'Failed to setup keys using terminfo (application mode unsuported).\n' |
|
|
|
|
|
|
|
# TODO: set zkbd mode |
|
|
|
|
|
|
|
# See: https://github.com/vinipsmaker/dotfiles/blob/master/config/.zshrc |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ -n "${key[Up]}" ]] && [[ -n "${key[Down]}" ]]; then |
|
|
|
function bind2maps () { |
|
|
|
|
|
|
|
local i sequence widget |
|
|
|
|
|
|
|
local -a maps |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while [[ "$1" != "--" ]]; do |
|
|
|
|
|
|
|
maps+=( "$1" ) |
|
|
|
|
|
|
|
shift |
|
|
|
|
|
|
|
done |
|
|
|
|
|
|
|
shift |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sequence="${key[$1]}" |
|
|
|
|
|
|
|
widget="$2" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[[ -z "$sequence" ]] && return 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i in "${maps[@]}"; do |
|
|
|
|
|
|
|
bindkey -M "$i" "$sequence" "$widget" |
|
|
|
|
|
|
|
done |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
autoload -U up-line-or-beginning-search |
|
|
|
autoload -U up-line-or-beginning-search |
|
|
|
autoload -U down-line-or-beginning-search |
|
|
|
autoload -U down-line-or-beginning-search |
|
|
|
zle -N up-line-or-beginning-search |
|
|
|
zle -N up-line-or-beginning-search |
|
|
|
zle -N down-line-or-beginning-search |
|
|
|
zle -N down-line-or-beginning-search |
|
|
|
|
|
|
|
|
|
|
|
bindkey "${key[Up]}" up-line-or-beginning-search |
|
|
|
bind2maps emacs -- BackSpace backward-delete-char |
|
|
|
bindkey "${key[Down]}" down-line-or-beginning-search |
|
|
|
bind2maps viins -- BackSpace vi-backward-delete-char |
|
|
|
fi |
|
|
|
bind2maps vicmd -- BackSpace vi-backward-char |
|
|
|
[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" up-line-or-history |
|
|
|
bind2maps emacs -- Home beginning-of-line |
|
|
|
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" down-line-or-history |
|
|
|
bind2maps viins vicmd -- Home vi-beginning-of-line |
|
|
|
|
|
|
|
bind2maps emacs -- End end-of-line |
|
|
|
|
|
|
|
bind2maps viins vicmd -- End vi-end-of-line |
|
|
|
|
|
|
|
bind2maps emacs viins -- Insert overwrite-mode |
|
|
|
|
|
|
|
bind2maps vicmd -- Insert vi-insert |
|
|
|
|
|
|
|
bind2maps emacs -- Delete delete-char |
|
|
|
|
|
|
|
bind2maps viins vicmd -- Delete vi-delete-char |
|
|
|
|
|
|
|
bind2maps emacs viins vicmd -- Up up-line-or-beginning-search |
|
|
|
|
|
|
|
bind2maps emacs viins vicmd -- Down down-line-or-beginning-search |
|
|
|
|
|
|
|
bind2maps emacs -- Left backward-char |
|
|
|
|
|
|
|
bind2maps viins vicmd -- Left vi-backward-char |
|
|
|
|
|
|
|
bind2maps emacs -- Right forward-char |
|
|
|
|
|
|
|
bind2maps viins vicmd -- Right vi-forward-char |
|
|
|
|
|
|
|
bind2maps emacs viins vicmd -- PageUp up-line-or-history |
|
|
|
|
|
|
|
bind2maps emacs viins vicmd -- PageDown down-line-or-history |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unfunction bind2maps |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
# Fallback to manually managed user-driven database |
|
|
|
|
|
|
|
printf 'Failed to setup keys using terminfo (application mode unsuported).\n' |
|
|
|
|
|
|
|
# TODO: set zkbd mode |
|
|
|
|
|
|
|
# See: https://github.com/vinipsmaker/dotfiles/blob/master/config/.zshrc |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
### Completion (dump) |
|
|
|
### Completion (dump) |
|
|
|
# Note: This stuff probably has to be run before defining completion configs |
|
|
|
# Note: This stuff probably has to be run before defining completion configs |
|
|
|