diff --git a/zsh.d/bindings.zsh b/zsh.d/bindings.zsh new file mode 100644 index 0000000..3a738cc --- /dev/null +++ b/zsh.d/bindings.zsh @@ -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 diff --git a/zshrc b/zshrc index e64fa7a..cb57dfc 100644 --- a/zshrc +++ b/zshrc @@ -427,67 +427,6 @@ function title_preexec { add-zsh-hook preexec title_preexec 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 ---------------------------------- # Use interactive sudo instead of su