53 lines
1.9 KiB
Bash
53 lines
1.9 KiB
Bash
# Emacs mode
|
|
bindkey -e
|
|
|
|
# Make terminal keys work
|
|
if [[ -n ${terminfo[smkx]} && -n ${terminfo[rmkx]} ]]; then
|
|
autoload -Uz add-zle-hook-widget
|
|
zle-application-mode () { echoti smkx }
|
|
zle-application-mode-stop () { echoti rmkx }
|
|
add-zle-hook-widget -Uz zle-line-init zle-application-mode
|
|
add-zle-hook-widget -Uz zle-line-finish zle-application-mode-stop
|
|
fi
|
|
|
|
# History search with arrows
|
|
autoload -U up-line-or-beginning-search down-line-or-beginning-search
|
|
zle -N up-line-or-beginning-search
|
|
zle -N down-line-or-beginning-search
|
|
bindkey '^[[A' up-line-or-beginning-search
|
|
bindkey '^[[B' down-line-or-beginning-search
|
|
|
|
# Standard keys
|
|
bindkey '^[[H' beginning-of-line # Home
|
|
bindkey '^[[F' end-of-line # End
|
|
bindkey '^[[3~' delete-char # Delete
|
|
bindkey '^[[3;5~' kill-word # Ctrl+Delete
|
|
bindkey '^[[1;5C' forward-word # Ctrl+Right
|
|
bindkey '^[[1;5D' backward-word # Ctrl+Left
|
|
bindkey '^[[Z' reverse-menu-complete # Shift+Tab
|
|
bindkey '^R' history-incremental-search-backward
|
|
bindkey ' ' magic-space # Do history expansion on space
|
|
|
|
# Useful extras
|
|
bindkey '^U' backward-kill-line # Ctrl+U - delete from cursor to start
|
|
bindkey '^K' kill-line # Ctrl+K - delete from cursor to end
|
|
bindkey '^W' backward-kill-word # Ctrl+W - delete word backwards
|
|
bindkey '^[[1;3D' backward-word # Alt+Left
|
|
bindkey '^[[1;3C' forward-word # Alt+Right
|
|
bindkey '^L' clear-screen # Ctrl+L - clear screen
|
|
bindkey '^A' beginning-of-line # Ctrl+A - go to start
|
|
bindkey '^E' end-of-line # Ctrl+E - go to end
|
|
|
|
# Edit command in $EDITOR
|
|
autoload -U edit-command-line
|
|
zle -N edit-command-line
|
|
bindkey '^X^E' edit-command-line
|
|
|
|
# Undo/Redo
|
|
bindkey '^Z' undo # Ctrl+Z - undo
|
|
bindkey '^Y' redo # Ctrl+Y - redo
|
|
|
|
# Better word navigation (bash-style)
|
|
autoload -U select-word-style
|
|
select-word-style bash
|