Move bindings as partial

This commit is contained in:
Paweł Płazieński 2024-02-27 20:56:34 +01:00
parent 035ece152b
commit ac77e7dfdb
2 changed files with 60 additions and 61 deletions

60
zsh.d/bindings.zsh Normal file
View File

@ -0,0 +1,60 @@
# vim: ft=zsh
bindkey -v
# General movement
# Taken from http://wiki.archlinux.org/index.php/Zsh and Ubuntu's inputrc
bindkey "\e[1~" beginning-of-line
bindkey "\e[4~" end-of-line
bindkey "\e[5~" beginning-of-history
bindkey "\e[6~" end-of-history
bindkey "\e[3~" delete-char
bindkey "\e[2~" quoted-insert
bindkey "\e[1;5C" forward-word
bindkey "\e[1;5D" backward-word
bindkey "\e[5C" forward-word
bindkey "\eOc" emacs-forward-word
bindkey "\e[5D" backward-word
bindkey "\eOd" emacs-backward-word
bindkey "\e\e[C" forward-word
bindkey "\e\e[D" backward-word
bindkey ' ' magic-space # do history expansion on space
# for non RH/Debian xterm, can't hurt for RH/Debian xterm
bindkey "\eOH" beginning-of-line
bindkey "\eOF" end-of-line
# for freebsd console
bindkey "\e[H" beginning-of-line
bindkey "\e[F" end-of-line
# Tab completion
expand-or-complete-with-indicator() {
print -Pn "%{%F{red}...%f%}"
zle expand-or-complete
zle redisplay
}
zle -N expand-or-complete-with-indicator
bindkey "^I" expand-or-complete-with-indicator
bindkey "^r" history-incremental-search-backward
bindkey "\e[Z" reverse-menu-complete # shift-tab to reverse menu
# Up/down arrow.
# I want shared history for ^R, but I don't want another shell's activity to
# mess with up/down. This does that.
down-line-or-local-history() {
zle set-local-history 1
zle down-line-or-history
zle set-local-history 0
}
zle -N down-line-or-local-history
up-line-or-local-history() {
zle set-local-history 1
zle up-line-or-history
zle set-local-history 0
}
zle -N up-line-or-local-history
bindkey "\e[A" up-line-or-local-history
bindkey "\e[B" down-line-or-local-history

61
zshrc
View File

@ -427,67 +427,6 @@ function title_preexec {
add-zsh-hook preexec title_preexec add-zsh-hook preexec title_preexec
add-zsh-hook precmd title_precmd add-zsh-hook precmd title_precmd
#---------------------------------- Bindings ----------------------------------
bindkey -v
# General movement
# Taken from http://wiki.archlinux.org/index.php/Zsh and Ubuntu's inputrc
bindkey "\e[1~" beginning-of-line
bindkey "\e[4~" end-of-line
bindkey "\e[5~" beginning-of-history
bindkey "\e[6~" end-of-history
bindkey "\e[3~" delete-char
bindkey "\e[2~" quoted-insert
bindkey "\e[1;5C" forward-word
bindkey "\e[1;5D" backward-word
bindkey "\e[5C" forward-word
bindkey "\eOc" emacs-forward-word
bindkey "\e[5D" backward-word
bindkey "\eOd" emacs-backward-word
bindkey "\e\e[C" forward-word
bindkey "\e\e[D" backward-word
bindkey ' ' magic-space # do history expansion on space
# for non RH/Debian xterm, can't hurt for RH/Debian xterm
bindkey "\eOH" beginning-of-line
bindkey "\eOF" end-of-line
# for freebsd console
bindkey "\e[H" beginning-of-line
bindkey "\e[F" end-of-line
# Tab completion
expand-or-complete-with-indicator() {
print -Pn "%{%F{red}...%f%}"
zle expand-or-complete
zle redisplay
}
zle -N expand-or-complete-with-indicator
bindkey "^I" expand-or-complete-with-indicator
bindkey "^r" history-incremental-search-backward
bindkey "\e[Z" reverse-menu-complete # shift-tab to reverse menu
# Up/down arrow.
# I want shared history for ^R, but I don't want another shell's activity to
# mess with up/down. This does that.
down-line-or-local-history() {
zle set-local-history 1
zle down-line-or-history
zle set-local-history 0
}
zle -N down-line-or-local-history
up-line-or-local-history() {
zle set-local-history 1
zle up-line-or-history
zle set-local-history 0
}
zle -N up-line-or-local-history
bindkey "\e[A" up-line-or-local-history
bindkey "\e[B" down-line-or-local-history
#---------------------------------- Aliases ---------------------------------- #---------------------------------- Aliases ----------------------------------
# Use interactive sudo instead of su # Use interactive sudo instead of su