changeset 151:87498dbd779a

Move away from oh-my-zsh
author zegervdv <zegervdv@me.com>
date Mon, 20 Oct 2014 21:49:21 +0200
parents de8d4246c8fe
children 884d14e94710
files zsh/aliases.zsh zsh/bindkeys.zsh zsh/colors.zsh zsh/completion.zsh zsh/exports.zsh zsh/history.zsh zsh/prompt.zsh zsh/setopt.zsh zsh/z.sh zsh/zsh-history-substring-search.zsh zsh/zsh_hooks.zsh zshrc zshrc.old
diffstat 13 files changed, 1356 insertions(+), 174 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zsh/aliases.zsh	Mon Oct 20 21:49:21 2014 +0200
@@ -0,0 +1,34 @@
+# Listing directories and files
+alias l="ls -ltrhG"
+alias ll="ls -althrG"
+
+# Git shortcuts
+alias g='git'
+alias ga='git add'
+alias gaa='git add --all --intent-to-add'
+alias gap='git add --patch'
+alias gb='git branch'
+alias gc='git commit -v'
+alias gca='git commit -a -v'
+alias gcm='git checkout master'
+alias gco='git checkout'
+alias gcount='git shortlog -sn'
+alias gd='git diff'
+alias gm='git merge'
+alias gp='git push'
+alias gup='git pull'
+alias gr='git rebase'
+alias grhh='git reset --hard HEAD'
+alias gsl='git sl'
+alias gst='git status'
+alias gsta='git stash'
+alias gstap='git stash apply'
+
+# Quick access to directories
+alias dot='cd ~/.dotfiles'
+
+# Bundle
+alias beer='bundle exec rake'
+
+# Ranger
+alias ranger="EDITOR=vim ranger"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zsh/bindkeys.zsh	Mon Oct 20 21:49:21 2014 +0200
@@ -0,0 +1,17 @@
+# To see the key combo you want to use just do:
+# cat > /dev/null
+# And press it
+
+bindkey "^K"      kill-whole-line                      # ctrl-k
+bindkey "^R"      history-incremental-search-backward  # ctrl-r
+bindkey "^A"      beginning-of-line                    # ctrl-a  
+bindkey "^E"      end-of-line                          # ctrl-e
+bindkey "[B"      history-search-forward               # down arrow
+bindkey "[A"      history-search-backward              # up arrow
+bindkey "^D"      delete-char                          # ctrl-d
+bindkey "^F"      forward-char                         # ctrl-f
+bindkey "^B"      backward-char                        # ctrl-b
+bindkey -e   # Default to standard emacs bindings, regardless of editor string
+# bind UP and DOWN arrow keys
+bindkey '^[[A' history-substring-search-up
+bindkey '^[[B' history-substring-search-down
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zsh/colors.zsh	Mon Oct 20 21:49:21 2014 +0200
@@ -0,0 +1,23 @@
+autoload colors; colors
+
+# The variables are wrapped in %{%}. This should be the case for every
+# variable that does not contain space.
+for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do
+  eval PR_$COLOR='%{$fg_no_bold[${(L)COLOR}]%}'
+  eval PR_BOLD_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
+done
+
+eval RESET='$reset_color'
+export PR_RED PR_GREEN PR_YELLOW PR_BLUE PR_WHITE PR_BLACK
+export PR_BOLD_RED PR_BOLD_GREEN PR_BOLD_YELLOW PR_BOLD_BLUE 
+export PR_BOLD_WHITE PR_BOLD_BLACK
+
+# Clear LSCOLORS
+unset LSCOLORS
+
+# Main change, you can see directories on a dark background
+#expor tLSCOLORS=gxfxcxdxbxegedabagacad
+
+export CLICOLOR=1
+export LS_COLORS=exfxcxdxbxegedabagacad
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zsh/completion.zsh	Mon Oct 20 21:49:21 2014 +0200
@@ -0,0 +1,74 @@
+# add in zsh-completions
+fpath=(/usr/local/share/zsh-completions $fpath)
+
+autoload -U compinit && compinit                                                                                       
+zmodload -i zsh/complist
+# GRML style completion
+# activate color-completion
+zstyle ':completion:*:default'         list-colors ${(s.:.)LS_COLORS}
+
+# format on completion
+zstyle ':completion:*:descriptions'    format $'%{\e[0;31m%}completing %B%d%b%{\e[0m%}'
+
+# automatically complete 'cd -<tab>' and 'cd -<ctrl-d>' with menu
+# zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
+
+# insert all expansions for expand completer
+zstyle ':completion:*:expand:*'        tag-order all-expansions
+zstyle ':completion:*:history-words'   list false
+
+# activate menu
+zstyle ':completion:*:history-words'   menu yes
+
+# ignore duplicate entries
+zstyle ':completion:*:history-words'   remove-all-dups yes
+zstyle ':completion:*:history-words'   stop yes
+
+# match uppercase from lowercase
+zstyle ':completion:*'                 matcher-list 'm:{a-z}={A-Z}'
+
+zstyle ':completion:*:matches'         group 'yes'
+zstyle ':completion:*'                 group-name ''
+if [[ "$NOMENU" -eq 0 ]] ; then
+  # if there are more than 5 options allow selecting from a menu
+  zstyle ':completion:*'               menu select=5
+else
+  # don't use any menus at all
+  setopt no_auto_menu
+fi
+
+zstyle ':completion:*:messages'        format '%d'
+zstyle ':completion:*:options'         auto-description '%d'
+
+# describe options in full
+zstyle ':completion:*:options'         description 'yes'
+
+# complete manual by their section
+zstyle ':completion:*:manuals'    separate-sections true
+zstyle ':completion:*:manuals.*'  insert-sections   true
+zstyle ':completion:*:man:*'      menu yes select
+
+# Search path for sudo completion
+zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \
+                                           /usr/local/bin  \
+                                           /usr/sbin       \
+                                           /usr/bin        \
+                                           /sbin           \
+                                           /bin            \
+                                           /usr/X11R6/bin
+
+# provide .. as a completion
+zstyle ':completion:*' specal-dirs ..
+
+
+zstyle ':completion::*:(m|)vim:*' ignored-patterns '*.(o|hex|elf|pyc|pdf|out|aux|toc|out|fls|bbl|synctex.gz|dvi|blg|fdb_latexmk)'
+
+# ag tab complete
+_ag() {
+  if (( CURRENT == 2 )); then
+    compadd $(cut -f 1 .git/tags tmp/tags 2>/dev/null | grep -v '!_TAG')
+  fi
+}
+
+compdef _ag ag
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zsh/exports.zsh	Mon Oct 20 21:49:21 2014 +0200
@@ -0,0 +1,31 @@
+export PATH=$PATH:/usr/local/opt/ruby/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin:/usr/local/sbin
+export PATH="/usr/local/bin:$PATH"
+export NODE_PATH="/usr/local/lib/node"
+export PATH="/usr/local/share/npm/bin:$PATH"
+export PATH=$PATH:$HOME/.bin
+# if rbenv is present, configure it for use
+if which rbenv &> /dev/null; then
+    # Put the rbenv entry at the front of the line
+    export PATH="$HOME/.rbenv/bin:$PATH"
+
+    # enable shims and auto-completion
+    eval "$(rbenv init -)"
+fi
+
+# Setup terminal, and turn on colors
+export TERM=xterm-256color
+export CLICOLOR=1
+export LSCOLORS=Gxfxcxdxbxegedabagacad
+
+# Enable color in grep
+export GREP_OPTIONS='--color=auto'
+export GREP_COLOR=32
+
+# This resolves issues install the mysql, postgres, and other gems with native non universal binary extensions
+export ARCHFLAGS='-arch x86_64'
+
+export LESS='--ignore-case --raw-control-chars'
+export PAGER='most'
+export EDITOR='vim'
+# CTAGS Sorting in VIM/Emacs is better behaved with this in place
+export LC_COLLATE=C
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zsh/history.zsh	Mon Oct 20 21:49:21 2014 +0200
@@ -0,0 +1,4 @@
+# HISTORY
+HISTSIZE=3000
+SAVEHIST=3000
+HISTFILE=~/.zsh_history
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zsh/prompt.zsh	Mon Oct 20 21:49:21 2014 +0200
@@ -0,0 +1,95 @@
+function get_pwd() {
+   echo "${PWD/$HOME/~}"
+}
+
+eval my_gray='$FG[237]'
+eval my_orange='$FG[214]'
+
+function parse_git_branch() {
+  (git symbolic-ref -q HEAD || git name-rev --name-only --no-undefined --always HEAD) 2> /dev/null
+}
+
+# Modify the colors and symbols in these variables as desired.
+GIT_PROMPT_PREFIX=""
+GIT_PROMPT_SUFFIX=""
+GIT_PROMPT_AHEAD="%{$fg[red]%} +NUM%{$reset_color%}"
+GIT_PROMPT_BEHIND="%{$fg[green]%} -NUM%{$reset_color%}"
+GIT_PROMPT_MERGING="%{$fg_bold[magenta]%}⚡︎%{$reset_color%}"
+GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} U%{$reset_color%}"
+GIT_PROMPT_MODIFIED="%{$fg[blue]%} M%{$reset_color%}"
+GIT_PROMPT_STAGED="%{$fg[green]%} A%{$reset_color%}"
+ 
+ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} U"
+ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} A"
+ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} D"
+ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} R"
+ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} M"
+ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} U"
+
+ZSH_THEME_GIT_PROMPT_PREFIX="${my_gray}"
+ZSH_THEME_GIT_PROMPT_CLEAN=""
+ZSH_THEME_GIT_PROMPT_DIRTY="%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_SUFFIX="$my_gray%{$reset_color%}"
+
+function parse_git_state() {
+# Compose this value via multiple conditional appends.
+  local GIT_STATE=""
+ 
+  local NUM_AHEAD="$(git log --oneline @{u}.. 2> /dev/null | wc -l | tr -d ' ')"
+  if [ "$NUM_AHEAD" -gt 0 ]; then
+    GIT_STATE=$GIT_STATE${GIT_PROMPT_AHEAD//NUM/$NUM_AHEAD}
+  fi
+ 
+  local NUM_BEHIND="$(git log --oneline ..@{u} 2> /dev/null | wc -l | tr -d ' ')"
+  if [ "$NUM_BEHIND" -gt 0 ]; then
+    GIT_STATE=$GIT_STATE${GIT_PROMPT_BEHIND//NUM/$NUM_BEHIND}
+  fi
+ 
+  local GIT_DIR="$(git rev-parse --git-dir 2> /dev/null)"
+  if [ -n $GIT_DIR ] && test -r $GIT_DIR/MERGE_HEAD; then
+    GIT_STATE=$GIT_STATE$GIT_PROMPT_MERGING
+  fi
+ 
+  if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
+    GIT_STATE=$GIT_STATE$GIT_PROMPT_UNTRACKED
+  fi
+ 
+  if ! git diff --quiet 2> /dev/null; then
+    GIT_STATE=$GIT_STATE$GIT_PROMPT_MODIFIED
+  fi
+ 
+  if ! git diff --cached --quiet 2> /dev/null; then
+    GIT_STATE=$GIT_STATE$GIT_PROMPT_STAGED
+  fi
+ 
+  if [[ -n $GIT_STATE ]]; then
+    echo "$GIT_PROMPT_PREFIX$GIT_STATE$GIT_PROMPT_SUFFIX"
+  fi
+}
+# If inside a Git repository, print its branch and state
+function git_prompt_string() {
+  local git_where="$(parse_git_branch)"
+  [ -n "$git_where" ] && echo "on %{$fg[blue]%}${git_where#(refs/heads/|tags/)}$(parse_git_state)"
+}
+local my_prompt_name='%n'  
+[[ "$SSH_CONNECTION" != '' ]] && my_prompt_name='%n@%m'
+
+PROMPT='%{$fg[cyan]%}$my_prompt_name%{$reset_color%} in %{$fg[yellow]%}%~%b%{$reset_color%}
+%{$reset_color%}%(1j.%j .)%(?.%{$fg[white]%}.%{$fg[red]%})→ %{$reset_color%}'
+
+
+RPROMPT='$my_gray $(git_prompt_string)%{$reset_color%}%'
+
+ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} U"
+ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} A"
+ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} D"
+ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} R"
+ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} M"
+ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} U"
+
+ZSH_THEME_GIT_PROMPT_PREFIX="${my_gray}"
+ZSH_THEME_GIT_PROMPT_CLEAN=""
+ZSH_THEME_GIT_PROMPT_DIRTY="%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_SUFFIX="$my_gray%{$reset_color%}"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zsh/setopt.zsh	Mon Oct 20 21:49:21 2014 +0200
@@ -0,0 +1,60 @@
+# ===== Basics
+
+# If you type foo, and it isn't a command, and it is a directory in your cdpath, go there
+setopt AUTO_CD
+setopt cdablevarS
+setopt pushd_ignore_dups
+
+# Allow comments even in interactive shells (especially for Muness)
+setopt INTERACTIVE_COMMENTS
+
+# ===== History
+
+# Allow multiple terminal sessions to all append to one zsh command history
+setopt APPEND_HISTORY 
+
+# Add comamnds as they are typed, don't wait until shell exit
+setopt INC_APPEND_HISTORY 
+
+# Do not write events to history that are duplicates of previous events
+setopt HIST_IGNORE_DUPS
+
+# When searching history don't display results already cycled through twice
+setopt HIST_FIND_NO_DUPS
+
+# Remove extra blanks from each command line being added to history
+setopt HIST_REDUCE_BLANKS
+
+# Include more information about when the command was executed, etc
+setopt EXTENDED_HISTORY
+
+setopt hist_expire_dups_first
+
+setopt hist_verify # Don't execute
+setopt share_history
+
+# ===== Completion 
+
+# Allow completion from within a word/phrase
+setopt COMPLETE_IN_WORD 
+
+# When completing from the middle of a word, move the cursor to the end of the word
+setopt ALWAYS_TO_END            
+
+# ===== Prompt
+
+# Enable parameter expansion, command substitution, and arithmetic expansion in the prompt
+setopt PROMPT_SUBST
+setopt transient_rprompt
+
+setopt multios
+
+
+unsetopt MENU_COMPLETE
+setopt AUTO_MENU
+
+setopt nobeep
+setopt notify
+REPORTTIME=5
+
+setopt correct_all
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zsh/z.sh	Mon Oct 20 21:49:21 2014 +0200
@@ -0,0 +1,243 @@
+# Copyright (c) 2009 rupa deadwyler under the WTFPL license
+
+# maintains a jump-list of the directories you actually use
+#
+# INSTALL:
+#     * put something like this in your .bashrc/.zshrc:
+#         . /path/to/z.sh
+#     * cd around for a while to build up the db
+#     * PROFIT!!
+#     * optionally:
+#         set $_Z_CMD in .bashrc/.zshrc to change the command (default z).
+#         set $_Z_DATA in .bashrc/.zshrc to change the datafile (default ~/.z).
+#         set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
+#         set $_Z_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself.
+#         set $_Z_EXCLUDE_DIRS to an array of directories to exclude.
+#         set $_Z_OWNER to your username if you want use z while sudo with $HOME kept
+#
+# USE:
+#     * z foo     # cd to most frecent dir matching foo
+#     * z foo bar # cd to most frecent dir matching foo and bar
+#     * z -r foo  # cd to highest ranked dir matching foo
+#     * z -t foo  # cd to most recently accessed dir matching foo
+#     * z -l foo  # list matches instead of cd
+#     * z -c foo  # restrict matches to subdirs of $PWD
+
+[ -d "${_Z_DATA:-$HOME/.z}" ] && {
+    echo "ERROR: z.sh's datafile (${_Z_DATA:-$HOME/.z}) is a directory."
+}
+
+_z() {
+
+    local datafile="${_Z_DATA:-$HOME/.z}"
+
+    # bail if we don't own ~/.z and $_Z_OWNER not set
+    [ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return
+
+    # add entries
+    if [ "$1" = "--add" ]; then
+        shift
+
+        # $HOME isn't worth matching
+        [ "$*" = "$HOME" ] && return
+
+        # don't track excluded dirs
+        local exclude
+        for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do
+            [ "$*" = "$exclude" ] && return
+        done
+
+        # maintain the data file
+        local tempfile="$datafile.$RANDOM"
+        while read line; do
+            # only count directories
+            [ -d "${line%%\|*}" ] && echo $line
+        done < "$datafile" | awk -v path="$*" -v now="$(date +%s)" -F"|" '
+            BEGIN {
+                rank[path] = 1
+                time[path] = now
+            }
+            $2 >= 1 {
+                # drop ranks below 1
+                if( $1 == path ) {
+                    rank[$1] = $2 + 1
+                    time[$1] = now
+                } else {
+                    rank[$1] = $2
+                    time[$1] = $3
+                }
+                count += $2
+            }
+            END {
+                if( count > 9000 ) {
+                    # aging
+                    for( x in rank ) print x "|" 0.99*rank[x] "|" time[x]
+                } else for( x in rank ) print x "|" rank[x] "|" time[x]
+            }
+        ' 2>/dev/null >| "$tempfile"
+        # do our best to avoid clobbering the datafile in a race condition
+        if [ $? -ne 0 -a -f "$datafile" ]; then
+            env rm -f "$tempfile"
+        else
+            [ "$_Z_OWNER" ] && chown $_Z_OWNER:$(id -ng $_Z_OWNER) "$tempfile"
+            env mv -f "$tempfile" "$datafile" || env rm -f "$tempfile"
+        fi
+
+    # tab completion
+    elif [ "$1" = "--complete" -a -s "$datafile" ]; then
+        while read line; do
+            [ -d "${line%%\|*}" ] && echo $line
+        done < "$datafile" | awk -v q="$2" -F"|" '
+            BEGIN {
+                if( q == tolower(q) ) imatch = 1
+                q = substr(q, 3)
+                gsub(" ", ".*", q)
+            }
+            {
+                if( imatch ) {
+                    if( tolower($1) ~ tolower(q) ) print $1
+                } else if( $1 ~ q ) print $1
+            }
+        ' 2>/dev/null
+
+    else
+        # list/go
+        while [ "$1" ]; do case "$1" in
+            --) while [ "$1" ]; do shift; local fnd="$fnd${fnd:+ }$1";done;;
+            -*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
+                    c) local fnd="^$PWD $fnd";;
+                    h) echo "${_Z_CMD:-z} [-chlrtx] args" >&2; return;;
+                    x) sed -i -e "\:^${PWD}|.*:d" "$datafile";;
+                    l) local list=1;;
+                    r) local typ="rank";;
+                    t) local typ="recent";;
+                esac; opt=${opt:1}; done;;
+             *) local fnd="$fnd${fnd:+ }$1";;
+        esac; local last=$1; shift; done
+        [ "$fnd" -a "$fnd" != "^$PWD " ] || local list=1
+
+        # if we hit enter on a completion just go there
+        case "$last" in
+            # completions will always start with /
+            /*) [ -z "$list" -a -d "$last" ] && cd "$last" && return;;
+        esac
+
+        # no file yet
+        [ -f "$datafile" ] || return
+
+        local cd
+        cd="$(while read line; do
+            [ -d "${line%%\|*}" ] && echo $line
+        done < "$datafile" | awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
+            function frecent(rank, time) {
+                # relate frequency and time
+                dx = t - time
+                if( dx < 3600 ) return rank * 4
+                if( dx < 86400 ) return rank * 2
+                if( dx < 604800 ) return rank / 2
+                return rank / 4
+            }
+            function output(files, out, common) {
+                # list or return the desired directory
+                if( list ) {
+                    cmd = "sort -n >&2"
+                    for( x in files ) {
+                        if( files[x] ) printf "%-10s %s\n", files[x], x | cmd
+                    }
+                    if( common ) {
+                        printf "%-10s %s\n", "common:", common > "/dev/stderr"
+                    }
+                } else {
+                    if( common ) out = common
+                    print out
+                }
+            }
+            function common(matches) {
+                # find the common root of a list of matches, if it exists
+                for( x in matches ) {
+                    if( matches[x] && (!short || length(x) < length(short)) ) {
+                        short = x
+                    }
+                }
+                if( short == "/" ) return
+                # use a copy to escape special characters, as we want to return
+                # the original. yeah, this escaping is awful.
+                clean_short = short
+                gsub(/[\(\)\[\]\|]/, "\\\\&", clean_short)
+                for( x in matches ) if( matches[x] && x !~ clean_short ) return
+                return short
+            }
+            BEGIN {
+                gsub(" ", ".*", q)
+                hi_rank = ihi_rank = -9999999999
+            }
+            {
+                if( typ == "rank" ) {
+                    rank = $2
+                } else if( typ == "recent" ) {
+                    rank = $3 - t
+                } else rank = frecent($2, $3)
+                if( $1 ~ q ) {
+                    matches[$1] = rank
+                } else if( tolower($1) ~ tolower(q) ) imatches[$1] = rank
+                if( matches[$1] && matches[$1] > hi_rank ) {
+                    best_match = $1
+                    hi_rank = matches[$1]
+                } else if( imatches[$1] && imatches[$1] > ihi_rank ) {
+                    ibest_match = $1
+                    ihi_rank = imatches[$1]
+                }
+            }
+            END {
+                # prefer case sensitive
+                if( best_match ) {
+                    output(matches, best_match, common(matches))
+                } else if( ibest_match ) {
+                    output(imatches, ibest_match, common(imatches))
+                }
+            }
+        ')"
+        [ $? -gt 0 ] && return
+        [ "$cd" ] && cd "$cd"
+    fi
+}
+
+alias ${_Z_CMD:-z}='_z 2>&1'
+
+[ "$_Z_NO_RESOLVE_SYMLINKS" ] || _Z_RESOLVE_SYMLINKS="-P"
+
+if compctl >/dev/null 2>&1; then
+    # zsh
+    [ "$_Z_NO_PROMPT_COMMAND" ] || {
+        # populate directory list, avoid clobbering any other precmds.
+        if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then
+            _z_precmd() {
+                _z --add "${PWD:a}"
+            }
+        else
+            _z_precmd() {
+                _z --add "${PWD:A}"
+            }
+        fi
+        [[ -n "${precmd_functions[(r)_z_precmd]}" ]] || {
+            precmd_functions[$(($#precmd_functions+1))]=_z_precmd
+        }
+    }
+    _z_zsh_tab_completion() {
+        # tab completion
+        local compl
+        read -l compl
+        reply=(${(f)"$(_z --complete "$compl")"})
+    }
+    compctl -U -K _z_zsh_tab_completion _z
+elif complete >/dev/null 2>&1; then
+    # bash
+    # tab completion
+    complete -o filenames -C '_z --complete "$COMP_LINE"' ${_Z_CMD:-z}
+    [ "$_Z_NO_PROMPT_COMMAND" ] || {
+        # populate directory list. avoid clobbering other PROMPT_COMMANDs.
+        grep "_z --add" <<< "$PROMPT_COMMAND" >/dev/null || {
+            PROMPT_COMMAND="$PROMPT_COMMAND"$'\n''_z --add "$(command pwd '$_Z_RESOLVE_SYMLINKS' 2>/dev/null)" 2>/dev/null;'
+        }
+    }
+fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zsh/zsh-history-substring-search.zsh	Mon Oct 20 21:49:21 2014 +0200
@@ -0,0 +1,561 @@
+#!/usr/bin/env zsh
+##############################################################################
+#
+# Copyright (c) 2009 Peter Stephenson
+# Copyright (c) 2011 Guido van Steen
+# Copyright (c) 2011 Suraj N. Kurapati
+# Copyright (c) 2011 Sorin Ionescu
+# Copyright (c) 2011 Vincent Guerci
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+#
+#  * Redistributions in binary form must reproduce the above
+#    copyright notice, this list of conditions and the following
+#    disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#
+#  * Neither the name of the FIZSH nor the names of its contributors
+#    may be used to endorse or promote products derived from this
+#    software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+##############################################################################
+
+#-----------------------------------------------------------------------------
+# configuration variables
+#-----------------------------------------------------------------------------
+
+HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold'
+HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold'
+HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i'
+
+#-----------------------------------------------------------------------------
+# the main ZLE widgets
+#-----------------------------------------------------------------------------
+
+function history-substring-search-up() {
+  _history-substring-search-begin
+
+  _history-substring-search-up-history ||
+  _history-substring-search-up-buffer ||
+  _history-substring-search-up-search
+
+  _history-substring-search-end
+}
+
+function history-substring-search-down() {
+  _history-substring-search-begin
+
+  _history-substring-search-down-history ||
+  _history-substring-search-down-buffer ||
+  _history-substring-search-down-search
+
+  _history-substring-search-end
+}
+
+zle -N history-substring-search-up
+zle -N history-substring-search-down
+
+#-----------------------------------------------------------------------------
+# implementation details
+#-----------------------------------------------------------------------------
+
+zmodload -F zsh/parameter
+
+#
+# We have to "override" some keys and widgets if the
+# zsh-syntax-highlighting plugin has not been loaded:
+#
+# https://github.com/nicoulaj/zsh-syntax-highlighting
+#
+if [[ $+functions[_zsh_highlight] -eq 0 ]]; then
+  #
+  # Dummy implementation of _zsh_highlight() that
+  # simply removes any existing highlights when the
+  # user inserts printable characters into $BUFFER.
+  #
+  function _zsh_highlight() {
+    if [[ $KEYS == [[:print:]] ]]; then
+      region_highlight=()
+    fi
+  }
+
+  #
+  # The following snippet was taken from the zsh-syntax-highlighting project:
+  #
+  # https://github.com/zsh-users/zsh-syntax-highlighting/blob/56b134f5d62ae3d4e66c7f52bd0cc2595f9b305b/zsh-syntax-highlighting.zsh#L126-161
+  #
+  # Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
+  # All rights reserved.
+  #
+  # Redistribution and use in source and binary forms, with or without
+  # modification, are permitted provided that the following conditions are
+  # met:
+  #
+  #  * Redistributions of source code must retain the above copyright
+  #    notice, this list of conditions and the following disclaimer.
+  #
+  #  * Redistributions in binary form must reproduce the above copyright
+  #    notice, this list of conditions and the following disclaimer in the
+  #    documentation and/or other materials provided with the distribution.
+  #
+  #  * Neither the name of the zsh-syntax-highlighting contributors nor the
+  #    names of its contributors may be used to endorse or promote products
+  #    derived from this software without specific prior written permission.
+  #
+  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+  # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+  # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+  # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+  # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+  # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+  # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+  # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+  # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+  # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+  # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  #
+  #--------------8<-------------------8<-------------------8<-----------------
+  # Rebind all ZLE widgets to make them invoke _zsh_highlights.
+  _zsh_highlight_bind_widgets()
+  {
+    # Load ZSH module zsh/zleparameter, needed to override user defined widgets.
+    zmodload zsh/zleparameter 2>/dev/null || {
+      echo 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' >&2
+      return 1
+    }
+
+    # Override ZLE widgets to make them invoke _zsh_highlight.
+    local cur_widget
+    for cur_widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|run-help|which-command|beep)}; do
+      case $widgets[$cur_widget] in
+
+        # Already rebound event: do nothing.
+        user:$cur_widget|user:_zsh_highlight_widget_*);;
+
+        # User defined widget: override and rebind old one with prefix "orig-".
+        user:*) eval "zle -N orig-$cur_widget ${widgets[$cur_widget]#*:}; \
+                      _zsh_highlight_widget_$cur_widget() { builtin zle orig-$cur_widget -- \"\$@\" && _zsh_highlight }; \
+                      zle -N $cur_widget _zsh_highlight_widget_$cur_widget";;
+
+        # Completion widget: override and rebind old one with prefix "orig-".
+        completion:*) eval "zle -C orig-$cur_widget ${${widgets[$cur_widget]#*:}/:/ }; \
+                            _zsh_highlight_widget_$cur_widget() { builtin zle orig-$cur_widget -- \"\$@\" && _zsh_highlight }; \
+                            zle -N $cur_widget _zsh_highlight_widget_$cur_widget";;
+
+        # Builtin widget: override and make it call the builtin ".widget".
+        builtin) eval "_zsh_highlight_widget_$cur_widget() { builtin zle .$cur_widget -- \"\$@\" && _zsh_highlight }; \
+                       zle -N $cur_widget _zsh_highlight_widget_$cur_widget";;
+
+        # Default: unhandled case.
+        *) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;;
+      esac
+    done
+  }
+  #-------------->8------------------->8------------------->8-----------------
+
+  _zsh_highlight_bind_widgets
+fi
+
+function _history-substring-search-begin() {
+  setopt localoptions extendedglob
+
+  _history_substring_search_refresh_display=
+  _history_substring_search_query_highlight=
+
+  #
+  # Continue using the previous $_history_substring_search_result by default,
+  # unless the current query was cleared or a new/different query was entered.
+  #
+  if [[ -z $BUFFER || $BUFFER != $_history_substring_search_result ]]; then
+    #
+    # For the purpose of highlighting we will also keep
+    # a version without doubly-escaped meta characters.
+    #
+    _history_substring_search_query=$BUFFER
+
+    #
+    # $BUFFER contains the text that is in the command-line currently.
+    # we put an extra "\\" before meta characters such as "\(" and "\)",
+    # so that they become "\\\(" and "\\\)".
+    #
+    _history_substring_search_query_escaped=${BUFFER//(#m)[\][()|\\*?#<>~^]/\\$MATCH}
+
+    #
+    # Find all occurrences of the search query in the history file.
+    #
+    # (k) turns it an array of line numbers.
+    #
+    # (on) seems to remove duplicates, which are default
+    #      options. They can be turned off by (ON).
+    #
+    _history_substring_search_matches=(${(kon)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)*${_history_substring_search_query_escaped}*]})
+
+    #
+    # Define the range of values that $_history_substring_search_match_index
+    # can take: [0, $_history_substring_search_matches_count_plus].
+    #
+    _history_substring_search_matches_count=$#_history_substring_search_matches
+    _history_substring_search_matches_count_plus=$(( _history_substring_search_matches_count + 1 ))
+    _history_substring_search_matches_count_sans=$(( _history_substring_search_matches_count - 1 ))
+
+    #
+    # If $_history_substring_search_match_index is equal to
+    # $_history_substring_search_matches_count_plus, this indicates that we
+    # are beyond the beginning of $_history_substring_search_matches.
+    #
+    # If $_history_substring_search_match_index is equal to 0, this indicates
+    # that we are beyond the end of $_history_substring_search_matches.
+    #
+    # If we have initially pressed "up" we have to initialize
+    # $_history_substring_search_match_index to
+    # $_history_substring_search_matches_count_plus so that it will be
+    # decreased to $_history_substring_search_matches_count.
+    #
+    # If we have initially pressed "down" we have to initialize
+    # $_history_substring_search_match_index to
+    # $_history_substring_search_matches_count so that it will be increased to
+    # $_history_substring_search_matches_count_plus.
+    #
+    if [[ $WIDGET == history-substring-search-down ]]; then
+       _history_substring_search_match_index=$_history_substring_search_matches_count
+    else
+      _history_substring_search_match_index=$_history_substring_search_matches_count_plus
+    fi
+  fi
+}
+
+function _history-substring-search-end() {
+  setopt localoptions extendedglob
+
+  _history_substring_search_result=$BUFFER
+
+  # the search was succesful so display the result properly by clearing away
+  # existing highlights and moving the cursor to the end of the result buffer
+  if [[ $_history_substring_search_refresh_display -eq 1 ]]; then
+    region_highlight=()
+    CURSOR=${#BUFFER}
+  fi
+
+  # highlight command line using zsh-syntax-highlighting
+  _zsh_highlight
+
+  # highlight the search query inside the command line
+  if [[ -n $_history_substring_search_query_highlight && -n $_history_substring_search_query ]]; then
+    #
+    # The following expression yields a variable $MBEGIN, which
+    # indicates the begin position + 1 of the first occurrence
+    # of _history_substring_search_query_escaped in $BUFFER.
+    #
+    : ${(S)BUFFER##(#m$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)($_history_substring_search_query##)}
+    local begin=$(( MBEGIN - 1 ))
+    local end=$(( begin + $#_history_substring_search_query ))
+    region_highlight+=("$begin $end $_history_substring_search_query_highlight")
+  fi
+
+  # For debugging purposes:
+  # zle -R "mn: "$_history_substring_search_match_index" m#: "${#_history_substring_search_matches}
+  # read -k -t 200 && zle -U $REPLY
+
+  # Exit successfully from the history-substring-search-* widgets.
+  return 0
+}
+
+function _history-substring-search-up-buffer() {
+  #
+  # Check if the UP arrow was pressed to move the cursor within a multi-line
+  # buffer. This amounts to three tests:
+  #
+  # 1. $#buflines -gt 1.
+  #
+  # 2. $CURSOR -ne $#BUFFER.
+  #
+  # 3. Check if we are on the first line of the current multi-line buffer.
+  #    If so, pressing UP would amount to leaving the multi-line buffer.
+  #
+  #    We check this by adding an extra "x" to $LBUFFER, which makes
+  #    sure that xlbuflines is always equal to the number of lines
+  #    until $CURSOR (including the line with the cursor on it).
+  #
+  local buflines XLBUFFER xlbuflines
+  buflines=(${(f)BUFFER})
+  XLBUFFER=$LBUFFER"x"
+  xlbuflines=(${(f)XLBUFFER})
+
+  if [[ $#buflines -gt 1 && $CURSOR -ne $#BUFFER && $#xlbuflines -ne 1 ]]; then
+    zle up-line-or-history
+    return 0
+  fi
+
+  return 1
+}
+
+function _history-substring-search-down-buffer() {
+  #
+  # Check if the DOWN arrow was pressed to move the cursor within a multi-line
+  # buffer. This amounts to three tests:
+  #
+  # 1. $#buflines -gt 1.
+  #
+  # 2. $CURSOR -ne $#BUFFER.
+  #
+  # 3. Check if we are on the last line of the current multi-line buffer.
+  #    If so, pressing DOWN would amount to leaving the multi-line buffer.
+  #
+  #    We check this by adding an extra "x" to $RBUFFER, which makes
+  #    sure that xrbuflines is always equal to the number of lines
+  #    from $CURSOR (including the line with the cursor on it).
+  #
+  local buflines XRBUFFER xrbuflines
+  buflines=(${(f)BUFFER})
+  XRBUFFER="x"$RBUFFER
+  xrbuflines=(${(f)XRBUFFER})
+
+  if [[ $#buflines -gt 1 && $CURSOR -ne $#BUFFER && $#xrbuflines -ne 1 ]]; then
+    zle down-line-or-history
+    return 0
+  fi
+
+  return 1
+}
+
+function _history-substring-search-up-history() {
+  #
+  # Behave like up in ZSH, except clear the $BUFFER
+  # when beginning of history is reached like in Fish.
+  #
+  if [[ -z $_history_substring_search_query ]]; then
+
+    # we have reached the absolute top of history
+    if [[ $HISTNO -eq 1 ]]; then
+      BUFFER=
+
+    # going up from somewhere below the top of history
+    else
+      zle up-line-or-history
+    fi
+
+    return 0
+  fi
+
+  return 1
+}
+
+function _history-substring-search-down-history() {
+  #
+  # Behave like down-history in ZSH, except clear the
+  # $BUFFER when end of history is reached like in Fish.
+  #
+  if [[ -z $_history_substring_search_query ]]; then
+
+    # going down from the absolute top of history
+    if [[ $HISTNO -eq 1 && -z $BUFFER ]]; then
+      BUFFER=${history[1]}
+      _history_substring_search_refresh_display=1
+
+    # going down from somewhere above the bottom of history
+    else
+      zle down-line-or-history
+    fi
+
+    return 0
+  fi
+
+  return 1
+}
+
+function _history-substring-search-not-found() {
+  #
+  # Nothing matched the search query, so put it back into the $BUFFER while
+  # highlighting it accordingly so the user can revise it and search again.
+  #
+  _history_substring_search_old_buffer=$BUFFER
+  BUFFER=$_history_substring_search_query
+  _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
+}
+
+function _history-substring-search-up-search() {
+  _history_substring_search_refresh_display=1
+
+  #
+  # Highlight matches during history-substring-up-search:
+  #
+  # The following constants have been initialized in
+  # _history-substring-search-up/down-search():
+  #
+  # $_history_substring_search_matches is the current list of matches
+  # $_history_substring_search_matches_count is the current number of matches
+  # $_history_substring_search_matches_count_plus is the current number of matches + 1
+  # $_history_substring_search_matches_count_sans is the current number of matches - 1
+  # $_history_substring_search_match_index is the index of the current match
+  #
+  # The range of values that $_history_substring_search_match_index can take
+  # is: [0, $_history_substring_search_matches_count_plus].  A value of 0
+  # indicates that we are beyond the end of
+  # $_history_substring_search_matches. A value of
+  # $_history_substring_search_matches_count_plus indicates that we are beyond
+  # the beginning of $_history_substring_search_matches.
+  #
+  # In _history-substring-search-up-search() the initial value of
+  # $_history_substring_search_match_index is
+  # $_history_substring_search_matches_count_plus.  This value is set in
+  # _history-substring-search-begin().  _history-substring-search-up-search()
+  # will initially decrease it to $_history_substring_search_matches_count.
+  #
+  if [[ $_history_substring_search_match_index -ge 2 ]]; then
+    #
+    # Highlight the next match:
+    #
+    # 1. Decrease the value of $_history_substring_search_match_index.
+    #
+    # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
+    #    to highlight the current buffer.
+    #
+    (( _history_substring_search_match_index-- ))
+    BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]]
+    _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
+
+  elif [[ $_history_substring_search_match_index -eq 1 ]]; then
+    #
+    # We will move beyond the end of $_history_substring_search_matches:
+    #
+    # 1. Decrease the value of $_history_substring_search_match_index.
+    #
+    # 2. Save the current buffer in $_history_substring_search_old_buffer,
+    #    so that it can be retrieved by
+    #    _history-substring-search-down-search() later.
+    #
+    # 3. Make $BUFFER equal to $_history_substring_search_query.
+    #
+    # 4. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
+    #    to highlight the current buffer.
+    #
+    (( _history_substring_search_match_index-- ))
+    _history-substring-search-not-found
+
+  elif [[ $_history_substring_search_match_index -eq $_history_substring_search_matches_count_plus ]]; then
+    #
+    # We were beyond the beginning of $_history_substring_search_matches but
+    # UP makes us move back to $_history_substring_search_matches:
+    #
+    # 1. Decrease the value of $_history_substring_search_match_index.
+    #
+    # 2. Restore $BUFFER from $_history_substring_search_old_buffer.
+    #
+    # 3. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
+    #    to highlight the current buffer.
+    #
+    (( _history_substring_search_match_index-- ))
+    BUFFER=$_history_substring_search_old_buffer
+    _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
+
+  else
+    #
+    # We are at the beginning of history and there are no further matches.
+    #
+    _history-substring-search-not-found
+  fi
+}
+
+function _history-substring-search-down-search() {
+  _history_substring_search_refresh_display=1
+
+  #
+  # Highlight matches during history-substring-up-search:
+  #
+  # The following constants have been initialized in
+  # _history-substring-search-up/down-search():
+  #
+  # $_history_substring_search_matches is the current list of matches
+  # $_history_substring_search_matches_count is the current number of matches
+  # $_history_substring_search_matches_count_plus is the current number of matches + 1
+  # $_history_substring_search_matches_count_sans is the current number of matches - 1
+  # $_history_substring_search_match_index is the index of the current match
+  #
+  # The range of values that $_history_substring_search_match_index can take
+  # is: [0, $_history_substring_search_matches_count_plus].  A value of 0
+  # indicates that we are beyond the end of
+  # $_history_substring_search_matches. A value of
+  # $_history_substring_search_matches_count_plus indicates that we are beyond
+  # the beginning of $_history_substring_search_matches.
+  #
+  # In _history-substring-search-down-search() the initial value of
+  # $_history_substring_search_match_index is
+  # $_history_substring_search_matches_count.  This value is set in
+  # _history-substring-search-begin().
+  # _history-substring-search-down-search() will initially increase it to
+  # $_history_substring_search_matches_count_plus.
+  #
+  if [[ $_history_substring_search_match_index -le $_history_substring_search_matches_count_sans ]]; then
+    #
+    # Highlight the next match:
+    #
+    # 1. Increase $_history_substring_search_match_index by 1.
+    #
+    # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
+    #    to highlight the current buffer.
+    #
+    (( _history_substring_search_match_index++ ))
+    BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]]
+    _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
+
+  elif [[ $_history_substring_search_match_index -eq $_history_substring_search_matches_count ]]; then
+    #
+    # We will move beyond the beginning of $_history_substring_search_matches:
+    #
+    # 1. Increase $_history_substring_search_match_index by 1.
+    #
+    # 2. Save the current buffer in $_history_substring_search_old_buffer, so
+    #    that it can be retrieved by _history-substring-search-up-search()
+    #    later.
+    #
+    # 3. Make $BUFFER equal to $_history_substring_search_query.
+    #
+    # 4. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
+    #    to highlight the current buffer.
+    #
+    (( _history_substring_search_match_index++ ))
+    _history-substring-search-not-found
+
+  elif [[ $_history_substring_search_match_index -eq 0 ]]; then
+    #
+    # We were beyond the end of $_history_substring_search_matches but DOWN
+    # makes us move back to the $_history_substring_search_matches:
+    #
+    # 1. Increase $_history_substring_search_match_index by 1.
+    #
+    # 2. Restore $BUFFER from $_history_substring_search_old_buffer.
+    #
+    # 3. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
+    #    to highlight the current buffer.
+    #
+    (( _history_substring_search_match_index++ ))
+    BUFFER=$_history_substring_search_old_buffer
+    _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
+
+  else
+    #
+    # We are at the end of history and there are no further matches.
+    #
+    _history-substring-search-not-found
+  fi
+}
+
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zsh/zsh_hooks.zsh	Mon Oct 20 21:49:21 2014 +0200
@@ -0,0 +1,20 @@
+function precmd {
+  # vcs_info
+  # Put the string "hostname::/full/directory/path" in the title bar:
+  echo -ne "\e]2;$PWD\a"
+
+  # Put the parentdir/currentdir in the tab
+  echo -ne "\e]1;$PWD:h:t/$PWD:t\a"
+}
+
+function set_running_app {
+  printf "\e]1; $PWD:t:$(history $HISTCMD | cut -b7- ) \a"
+}
+
+function preexec {
+  set_running_app
+}
+
+function postexec {
+  set_running_app
+}
--- a/zshrc	Mon Oct 20 09:43:28 2014 +0200
+++ b/zshrc	Mon Oct 20 21:49:21 2014 +0200
@@ -1,178 +1,20 @@
-# Path to your oh-my-zsh configuration.
-ZSH=$HOME/.oh-my-zsh
-
-# Set name of the theme to load.
-# Look in ~/.oh-my-zsh/themes/
-# Optionally, if you set this to "random", it'll load a random theme each
-# time that oh-my-zsh is loaded.
-ZSH_THEME="custom"
-setopt correct_all
-
-# Example aliases
-# alias zshconfig="mate ~/.zshrc"
-# alias ohmyzsh="mate ~/.oh-my-zsh"
-
-# Set to this to use case-sensitive completion
-# CASE_SENSITIVE="true"
-
-# Comment this out to disable bi-weekly auto-update checks
-# DISABLE_AUTO_UPDATE="true"
-
-# Uncomment to change how many often would you like to wait before auto-updates occur? (in days)
-# export UPDATE_ZSH_DAYS=13
-
-# Uncomment following line if you want to disable colors in ls
-# DISABLE_LS_COLORS="true"
-
-# Uncomment following line if you want to disable autosetting terminal title.
-# DISABLE_AUTO_TITLE="true"
-
-# Uncomment following line if you want red dots to be displayed while waiting for completion
-COMPLETION_WAITING_DOTS="true"
-
-# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
-# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
-# Example format: plugins=(rails git textmate ruby lighthouse)
-plugins=(git z textmate sublime ruby history-substring-search brew gitfast osx terminalapp vagrant web-search gitignore brew-cask rake-fast colorize colored-man extract)
-
-source $ZSH/oh-my-zsh.sh
-
-# source $ZSH/plugins/history-substring-search/history-substring-search.zsh
-
-setopt nobeep
-setopt notify
-REPORTTIME=5
-
-# GRML style completion
-# activate color-completion
-zstyle ':completion:*:default'         list-colors ${(s.:.)LS_COLORS}
-
-# format on completion
-zstyle ':completion:*:descriptions'    format $'%{\e[0;31m%}completing %B%d%b%{\e[0m%}'
-
-# automatically complete 'cd -<tab>' and 'cd -<ctrl-d>' with menu
-# zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
-
-# insert all expansions for expand completer
-zstyle ':completion:*:expand:*'        tag-order all-expansions
-zstyle ':completion:*:history-words'   list false
-
-# activate menu
-zstyle ':completion:*:history-words'   menu yes
-
-# ignore duplicate entries
-zstyle ':completion:*:history-words'   remove-all-dups yes
-zstyle ':completion:*:history-words'   stop yes
-
-# match uppercase from lowercase
-zstyle ':completion:*'                 matcher-list 'm:{a-z}={A-Z}'
+source ~/.zsh/colors.zsh
+source ~/.zsh/setopt.zsh
+source ~/.zsh/exports.zsh
+source ~/.zsh/prompt.zsh
+source ~/.zsh/completion.zsh
+source ~/.zsh/aliases.zsh
+source ~/.zsh/bindkeys.zsh
+source ~/.zsh/history.zsh
+source ~/.zsh/zsh_hooks.zsh
 
-zstyle ':completion:*:matches'         group 'yes'
-zstyle ':completion:*'                 group-name ''
-if [[ "$NOMENU" -eq 0 ]] ; then
-  # if there are more than 5 options allow selecting from a menu
-  zstyle ':completion:*'               menu select=5
-else
-  # don't use any menus at all
-  setopt no_auto_menu
-fi
-
-zstyle ':completion:*:messages'        format '%d'
-zstyle ':completion:*:options'         auto-description '%d'
-
-# describe options in full
-zstyle ':completion:*:options'         description 'yes'
-
-# complete manual by their section
-zstyle ':completion:*:manuals'    separate-sections true
-zstyle ':completion:*:manuals.*'  insert-sections   true
-zstyle ':completion:*:man:*'      menu yes select
-
-# Search path for sudo completion
-zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \
-                                           /usr/local/bin  \
-                                           /usr/sbin       \
-                                           /usr/bin        \
-                                           /sbin           \
-                                           /bin            \
-                                           /usr/X11R6/bin
-
-# provide .. as a completion
-zstyle ':completion:*' specal-dirs ..
-
-
-zstyle ':completion::*:(m|)vim:*' ignored-patterns '*.(o|hex|elf|pyc|pdf|out|aux|toc|out|fls|bbl|synctex.gz|dvi|blg|fdb_latexmk)'
-# Customize to your needs...
-export PATH=$PATH:/usr/local/opt/ruby/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin:/usr/local/sbin
-export PATH="/usr/local/bin:$PATH"
-export NODE_PATH="/usr/local/lib/node"
-export PATH="/usr/local/share/npm/bin:$PATH"
-export PATH=$PATH:$HOME/.bin
-eval "$(rbenv init -)"
+# Plugins
+source ~/.fzf.zsh
+source ~/.zsh/zsh-history-substring-search.zsh
+source ~/.zsh/z.sh
 
-
-export GNUTERM=X11
-export SVN_EDITOR=vim
-
-export CLICOLOR=1
-export LSCOLORS=GxFxCxDxBxegedabagaced
-
-export EDITOR='vim'
-
-export GREP_COLOR=32
-
-# Shortcuts
-alias blade="cd \"/Volumes/Blade 32GB/\""
-alias p="~/Documents/projects"
-
-# Commands
-alias grep="grep --color=auto"
-alias beer="bundle exec rake"
-alias ll="ls -altrh"
-alias l="ls -lthr"
-alias gsl="git sl"
-alias gaa='git add --all --intent-to-add'
-
-# Functions
-gcat () {
-        cat $1 | egrep "$2|$"
-}
-
-# alias ctags='$(brew --prefix ctags)/bin/ctags'
-
-# Disable Autocorrections
-alias tmux='nocorrect tmux'
-# alias mvim="reattach-to-user-namespace mvim"
-# alias vim="reattach-to-user-namespace vim"
-# alias ag="ag --color"
-alias dot="cd ~/.dotfiles"
-alias ranger="EDITOR=mvim ranger"
-
-# ag tab complete
-_ag() {
-  if (( CURRENT == 2 )); then
-    compadd $(cut -f 1 .git/tags tmp/tags 2>/dev/null | grep -v '!_TAG')
+precmd() {
+  if [[ -n "$TMUX" ]]; then
+    tmux setenv "$(tmux display -p 'TMUX_PWD_#D')" "$PWD"
   fi
 }
-
-compdef _ag ag
-
-compctl -g '~/.teamocil/*(:t:r)' teamocil
-
-[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local
-
-bindkey '\e[A' history-beginning-search-backward
-bindkey '\e[B' history-beginning-search-forward
-
-source ~/.fzf.zsh
-q() {
-  if [[ -z "$*" ]]; then
-    cd "$(_z -l 2>&1 | sed -n 's/^[ 0-9.,]*//p' | fzf)"
-  else
-    _z "$@"
-  fi
-}
-
-
-PERL_MB_OPT="--install_base \"/Users/zegervdv/perl5\""; export PERL_MB_OPT;
-PERL_MM_OPT="INSTALL_BASE=/Users/zegervdv/perl5"; export PERL_MM_OPT;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zshrc.old	Mon Oct 20 21:49:21 2014 +0200
@@ -0,0 +1,178 @@
+# Path to your oh-my-zsh configuration.
+ZSH=$HOME/.oh-my-zsh
+
+# Set name of the theme to load.
+# Look in ~/.oh-my-zsh/themes/
+# Optionally, if you set this to "random", it'll load a random theme each
+# time that oh-my-zsh is loaded.
+ZSH_THEME="custom"
+setopt correct_all
+
+# Example aliases
+# alias zshconfig="mate ~/.zshrc"
+# alias ohmyzsh="mate ~/.oh-my-zsh"
+
+# Set to this to use case-sensitive completion
+# CASE_SENSITIVE="true"
+
+# Comment this out to disable bi-weekly auto-update checks
+# DISABLE_AUTO_UPDATE="true"
+
+# Uncomment to change how many often would you like to wait before auto-updates occur? (in days)
+# export UPDATE_ZSH_DAYS=13
+
+# Uncomment following line if you want to disable colors in ls
+# DISABLE_LS_COLORS="true"
+
+# Uncomment following line if you want to disable autosetting terminal title.
+# DISABLE_AUTO_TITLE="true"
+
+# Uncomment following line if you want red dots to be displayed while waiting for completion
+COMPLETION_WAITING_DOTS="true"
+
+# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
+# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
+# Example format: plugins=(rails git textmate ruby lighthouse)
+plugins=(git z textmate sublime ruby history-substring-search brew gitfast osx terminalapp vagrant web-search gitignore brew-cask rake-fast colorize colored-man extract)
+
+source $ZSH/oh-my-zsh.sh
+
+# source $ZSH/plugins/history-substring-search/history-substring-search.zsh
+
+setopt nobeep
+setopt notify
+REPORTTIME=5
+
+# GRML style completion
+# activate color-completion
+zstyle ':completion:*:default'         list-colors ${(s.:.)LS_COLORS}
+
+# format on completion
+zstyle ':completion:*:descriptions'    format $'%{\e[0;31m%}completing %B%d%b%{\e[0m%}'
+
+# automatically complete 'cd -<tab>' and 'cd -<ctrl-d>' with menu
+# zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
+
+# insert all expansions for expand completer
+zstyle ':completion:*:expand:*'        tag-order all-expansions
+zstyle ':completion:*:history-words'   list false
+
+# activate menu
+zstyle ':completion:*:history-words'   menu yes
+
+# ignore duplicate entries
+zstyle ':completion:*:history-words'   remove-all-dups yes
+zstyle ':completion:*:history-words'   stop yes
+
+# match uppercase from lowercase
+zstyle ':completion:*'                 matcher-list 'm:{a-z}={A-Z}'
+
+zstyle ':completion:*:matches'         group 'yes'
+zstyle ':completion:*'                 group-name ''
+if [[ "$NOMENU" -eq 0 ]] ; then
+  # if there are more than 5 options allow selecting from a menu
+  zstyle ':completion:*'               menu select=5
+else
+  # don't use any menus at all
+  setopt no_auto_menu
+fi
+
+zstyle ':completion:*:messages'        format '%d'
+zstyle ':completion:*:options'         auto-description '%d'
+
+# describe options in full
+zstyle ':completion:*:options'         description 'yes'
+
+# complete manual by their section
+zstyle ':completion:*:manuals'    separate-sections true
+zstyle ':completion:*:manuals.*'  insert-sections   true
+zstyle ':completion:*:man:*'      menu yes select
+
+# Search path for sudo completion
+zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \
+                                           /usr/local/bin  \
+                                           /usr/sbin       \
+                                           /usr/bin        \
+                                           /sbin           \
+                                           /bin            \
+                                           /usr/X11R6/bin
+
+# provide .. as a completion
+zstyle ':completion:*' specal-dirs ..
+
+
+zstyle ':completion::*:(m|)vim:*' ignored-patterns '*.(o|hex|elf|pyc|pdf|out|aux|toc|out|fls|bbl|synctex.gz|dvi|blg|fdb_latexmk)'
+# Customize to your needs...
+export PATH=$PATH:/usr/local/opt/ruby/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin:/usr/local/sbin
+export PATH="/usr/local/bin:$PATH"
+export NODE_PATH="/usr/local/lib/node"
+export PATH="/usr/local/share/npm/bin:$PATH"
+export PATH=$PATH:$HOME/.bin
+eval "$(rbenv init -)"
+
+
+export GNUTERM=X11
+export SVN_EDITOR=vim
+
+export CLICOLOR=1
+export LSCOLORS=GxFxCxDxBxegedabagaced
+
+export EDITOR='vim'
+
+export GREP_COLOR=32
+
+# Shortcuts
+alias blade="cd \"/Volumes/Blade 32GB/\""
+alias p="~/Documents/projects"
+
+# Commands
+alias grep="grep --color=auto"
+alias beer="bundle exec rake"
+alias ll="ls -altrh"
+alias l="ls -lthr"
+alias gsl="git sl"
+alias gaa='git add --all --intent-to-add'
+
+# Functions
+gcat () {
+        cat $1 | egrep "$2|$"
+}
+
+# alias ctags='$(brew --prefix ctags)/bin/ctags'
+
+# Disable Autocorrections
+alias tmux='nocorrect tmux'
+# alias mvim="reattach-to-user-namespace mvim"
+# alias vim="reattach-to-user-namespace vim"
+# alias ag="ag --color"
+alias dot="cd ~/.dotfiles"
+alias ranger="EDITOR=mvim ranger"
+
+# ag tab complete
+_ag() {
+  if (( CURRENT == 2 )); then
+    compadd $(cut -f 1 .git/tags tmp/tags 2>/dev/null | grep -v '!_TAG')
+  fi
+}
+
+compdef _ag ag
+
+compctl -g '~/.teamocil/*(:t:r)' teamocil
+
+[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local
+
+bindkey '\e[A' history-beginning-search-backward
+bindkey '\e[B' history-beginning-search-forward
+
+source ~/.fzf.zsh
+q() {
+  if [[ -z "$*" ]]; then
+    cd "$(_z -l 2>&1 | sed -n 's/^[ 0-9.,]*//p' | fzf)"
+  else
+    _z "$@"
+  fi
+}
+
+
+PERL_MB_OPT="--install_base \"/Users/zegervdv/perl5\""; export PERL_MB_OPT;
+PERL_MM_OPT="INSTALL_BASE=/Users/zegervdv/perl5"; export PERL_MM_OPT;