Files
dots/.zsh/key-bindings.zsh
2018-07-16 21:22:48 +02:00

57 lines
1.7 KiB
Bash

# TODO: Explain what some of this does..
bindkey -e
bindkey -s '^g' '|grep ""^[OD' # c g pipe to grep
bindkey '\ew' kill-region
bindkey -s '\el' "ls\n"
bindkey -s '\ek' "..\n"
bindkey -s '\ej' "cd -\n"
bindkey -s '\eh' "cd $OLDPWD\n"
bindkey -s '\e;' "pushd -1\n"
bindkey -s '\ei' "dirs\n"
bindkey -s '\eo' "popd\n"
# Meta-u to chdir to the parent directory
bindkey -s '\eu' '^Ucd ..\n'
bindkey '^r' history-incremental-search-backward
bindkey "^[[5~" up-line-or-history
bindkey "^[[6~" down-line-or-history
# make search up and down work, so partially type and hit up/down to find relevant stuff
bindkey '^[[A' up-line-or-search
bindkey '^[[B' down-line-or-search
bindkey "^[[H" beginning-of-line
bindkey "^[[1~" beginning-of-line
bindkey "^[[F" end-of-line
bindkey "^[[4~" end-of-line
bindkey ' ' magic-space # also do history expansion on space
bindkey '^[[Z' reverse-menu-complete
# Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~
bindkey "^[[3~" delete-char
bindkey "^[3;5~" delete-char
bindkey "\e[3~" delete-char
# alt+s inserts sudo at the beginning of the line
insert_sudo () { zle beginning-of-line; zle -U "sudo " }
zle -N insert-sudo insert_sudo
bindkey "^[s" insert-sudo
# consider emacs keybindings:
#bindkey -e ## emacs key bindings
#
#bindkey '^[[A' up-line-or-search
#bindkey '^[[B' down-line-or-search
#bindkey '^[^[[C' emacs-forward-word
#bindkey '^[^[[D' emacs-backward-word
#
#bindkey -s '^X^Z' '%-^M'
#bindkey '^[e' expand-cmd-path
#bindkey '^[^I' reverse-menu-complete
#bindkey '^X^N' accept-and-infer-next-history
#bindkey '^W' kill-region
#bindkey '^I' complete-word
## Fix weird sequence that rxvt produces
#bindkey -s '^[[Z' '\t'
#