Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 102 lines (82 sloc) 3.29 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
# ~/.zshrc

HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000

setopt APPEND_HISTORY
setopt AUTO_CD
setopt AUTO_PUSHD
#setopt CORRECT_ALL
setopt EXTENDED_GLOB
setopt HASH_LIST_ALL
setopt HIST_IGNORE_ALL_DUPS
setopt INC_APPEND_HISTORY
setopt INTERACTIVE_COMMENTS
setopt MENU_COMPLETE
#setopt PROMPT_SUBST
setopt SHARE_HISTORY

unsetopt BEEP
#unsetopt CHECK_JOBS
unsetopt HUP

if [ -f "$HOME/.shellrc" ]; then
source "$HOME/.shellrc"
fi

# make zsh's 'time' output similar to bash's
TIMEFMT=$'\nreal\t%*E\nuser\t%*U\nsys\t%*S'

# use vi editing mode
bindkey -v

# use jk to exit insert mode
bindkey -M viins 'jk' vi-cmd-mode

# break default vi insert mode character deletion behaviour (like 'set backspace+=start' in vim)
bindkey -M viins '^?' backward-delete-char
bindkey -M viins '^H' backward-delete-char
#bindkey -M viins '^W' backward-kill-word
bindkey -M viins '^U' backward-kill-line

# changing viins keymap's default '^W' binding seems to break vi-mode word delimiter settings
# the following somewhat fixes this
#autoload -U select-word-style && select-word-style bash

# enable backwards search in insert mode
bindkey -M viins '^R' history-incremental-search-backward

# set alternative keys for tab completion
bindkey -M viins '^N' menu-complete
bindkey -M viins '^P' reverse-menu-complete

# search history based on first word in buffer
bindkey -M viins '^J' history-search-forward
bindkey -M viins '^K' history-search-backward

# leave menu selection and accept entire command line after '^M'
# default behaviour only leaves menuselect; doesn't execute command line
zmodload zsh/complist
bindkey -M menuselect '^M' .accept-line

# display current vi-mode in prompt string
VI_MODE="i"
function zle-line-init zle-keymap-select {
    VI_MODE="${${KEYMAP/vicmd/c}/(main|viins)/i}"
    if [ "$VI_MODE" = "i" ]; then
PROMPT="%n@%m:%1~ [%{$fg[red]%}${VI_MODE}%{$reset_color%}]$ "
    else
PROMPT="%n@%m:%1~ [%{$fg[green]%}${VI_MODE}%{$reset_color%}]$ "
    fi
zle reset-prompt
}

zle -N zle-line-init
zle -N zle-keymap-select

PROMPT="%n@%m:%1~ [%{$fg[red]%}${VI_MODE}%{$reset_color%}]$ "

# completion settings
#zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _complete _ignored
zstyle ':completion:*' expand prefix
#zstyle ':completion:*' format 'completing: %d'
#zstyle ':completion:*' group-name '' # organize completion list in groups
zstyle ':completion:*' insert-unambiguous true
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-prompt '%Sat %p: hit TAB for more, or the character to insert%s'
zstyle ':completion:*' matcher-list 'm:{[:lower:]}={[:upper:]}' 'r:|[._-]=* r:|=*'
#zstyle ':completion:*' matcher-list 'm:{[:lower:]}={[:upper:]}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' # with substring matching
zstyle ':completion:*' menu select=1 # shows highlight for selected completion item
zstyle ':completion:*' original true # offer original string as possible match
zstyle ':completion:*' preserve-prefix '//[^/]##/'
zstyle ':completion:*' select-prompt '%Sscrolling active: current selection at %p%s'
zstyle ':completion:*' use-cache on
zstyle :compinstall filename "$HOME/.zshrc"

autoload -Uz compinit && compinit

# enable zsh colours
autoload -U colors && colors
Something went wrong with that request. Please try again.