X-Git-Url: https://git.distorted.org.uk/~mdw/profile/blobdiff_plain/a797cf506518ceb00de8086572329d6cbba6fd4b..cba93353b8c3eafce56e7012788e6a3c7549b0c6:/dot/zshrc diff --git a/dot/zshrc b/dot/zshrc index b4992b7..8af418a 100644 --- a/dot/zshrc +++ b/dot/zshrc @@ -30,17 +30,65 @@ fi ###-------------------------------------------------------------------------- ### Line editing. -autoload -U select-word-style -select-word-style bash +case $TERM in dumb) unsetopt zle ;; esac + bindkey -e +for w in \ + forward-word backward-word kill-word backward-kill-word \ + transpose-words capitalize-word up-case-word down-case-word \ + delete-whole-word select-word +do + autoload -U $w-match + zle -N $w-bash $w-match + zle -N $w-shell $w-match + zstyle ':zle:*-bash' word-style standard + zstyle ':zle:*-bash' skip-whitespace-first true + zstyle ':zle:*-bash' word-chars "" + zstyle ':zle:*-shell' word-style shell + zstyle ':zle:*-shell' skip-whitespace-first false +done + +bindkey "\eb" backward-word-bash +bindkey "\e^b" backward-word-shell +bindkey "\ef" forward-word-bash +bindkey "\e^f" forward-word-shell +bindkey "\e^?" backward-kill-word-bash +bindkey "^w" backward-kill-word-shell +bindkey "\ed" kill-word-bash +bindkey "\e^d" kill-word-shell +bindkey "\et" transpose-words-bash +bindkey "\e^t" transpose-words-shell +bindkey "\eu" up-case-word-bash +bindkey "\e^u" up-case-word-shell +bindkey "\el" down-case-word-bash +bindkey "\e^l" down-case-word-shell +bindkey "\ec" capitalize-word-bash +bindkey "\e^c" capitalize-word-shell + +bindkey "\ep" history-beginning-search-backward +bindkey "\en" history-beginning-search-forward + +setopt interactive_comments +bindkey "\e#" pound-insert + +__mdw_delete_horizontal_space () { + LBUFFER=${LBUFFER%%[[:space:]]##} + RBUFFER=${RBUFFER##[[:space:]]##} +} +zle -N delete-horizontal-space __mdw_delete_horizontal_space +bindkey "\e\\" delete-horizontal-space + +__mdw_just_one_space () { + LBUFFER="${LBUFFER%%[[:space:]]##} " + RBUFFER=${RBUFFER##[[:space:]]##} +} +zle -N just-one-space __mdw_just_one_space +bindkey "\e " just-one-space + ###-------------------------------------------------------------------------- ### Completion. -## Initialize the fancy completion machinery. -autoload -Uz compinit -compinit - ## Contexts: :completion:FUNCTION:COMPLETER:COMMAND:ARGUMENT:TAG zstyle ':completion:*' completer _expand _complete _ignored _approximate zstyle ':completion:*' insert-unambiguous false @@ -52,6 +100,10 @@ zstyle ':completion:*' original true zstyle ':completion:*' verbose false zstyle ':completion:*:*:git*:*' verbose true +## Initialize the fancy completion machinery. +autoload -Uz compinit +compinit + _r () { words[1]=sudo; _normal; } compdef _r rootly compdef _ssh @ @@ -63,18 +115,21 @@ HISTFILE=~/.zsh-history HISTSIZE=1000 SAVEHIST=1000 -setopt appendhistory unsetopt auto_cd unsetopt auto_menu +setopt bang_hist unsetopt bash_auto_list unsetopt beep setopt extendedglob +unsetopt flow_control +setopt hist_ignore_all_dups setopt ksh_glob setopt list_ambiguous setopt list_packed unsetopt nomatch unsetopt menu_complete setopt notify +setopt share_history zshaddhistory () { case "$1" in