Re-import repository after cleanup from personal stuff (see description)
authorMikael Berthe <mikael@lilotux.net>
Sat, 14 Jul 2012 19:20:57 +0200
changeset 0 7215ca490221
child 1 7da32984f5b5
Re-import repository after cleanup from personal stuff (see description) I've remove too dirty or specific stuff, so that i could put this configuration on a public repo. Here's a copy of the initial Mercurial changelog, FWIW... * (2012-07-14) Mikael Berthe Reorganize all scripts * (2012-07-14) Mikael Berthe Add a "tools" directory * (2012-07-14) Mikael Berthe Don't use ^X^C as a keybinding * (2012-07-14) Mikael Berthe Disable ... completion for now * (2012-07-14) Mikael Berthe Add rehash key binding * (2012-07-14) Mikael Berthe Add n fix a few key bindings * (2012-07-14) Mikael Berthe More cleanup Remove zshrc_compinstall Move personnal stuff to zshrc_local * (2012-07-14) Mikael Berthe New commands: ...* Previous commands .. and ... have been renamed to ,, and ,,, * (2012-07-14) Mikael Berthe Add WATCHFMT, move REPORTTIME to zshenv * (2012-07-14) Mikael Berthe Add REPORTTIME * (2012-07-13) Mikael Berthe Add a few useful functions Ideas borrowed from https://github.com/whiteinge/dotfiles/blob/master/.zshrc * (2012-07-13) Mikael Berthe Move aliases to a new file * (2012-07-13) Mikael Berthe Check for zshrc_local existence * (2012-07-13) Mikael Berthe Cleanup vcsinfo prompt * (2012-07-12) Mikael Berthe Colorize time in default color prompt as well * (2012-07-12) Mikael Berthe Prompt: colorize time * (2012-07-12) Mikael Berthe Add a copy of git-prompt.sh * (2012-07-12) Mikael Berthe Update prompt themes Since we do not display the mode on the first line, let's use this place for the date/time. * (2012-07-12) Mikael Berthe Update prompts / new showmode * (2012-07-12) Mikael Berthe More showmode cleanup, part2 * (2012-07-12) Mikael Berthe Switch showmode to using RPROMPT, part1 * (2012-07-12) Mikael Berthe Prompt: many improvements and fixes * (2012-07-11) Mikael Berthe More prompt code cleanup * (2012-07-11) Mikael Berthe More readable prompt generation * (2012-07-11) Mikael Berthe Dynamic path color * (2012-07-11) Mikael Berthe New prompt based on Zsh' vcs_info module * (2012-07-10) Mikael Berthe Add git info, add a light dev2 prompt * (2012-07-10) Mikael Berthe Dev prompt: Improve Mercurial repository detection * (2012-07-08) Mikael Berthe hg prompt: Change color of unapplied patches * (2012-07-08) Mikael Berthe Change Mercurial prompt format * (2012-07-08) Mikael Berthe Try to improve showmode support. Enable it for 256 color terms. * (2012-07-08) Mikael Berthe Fix interaction between showmode and the new "dev" prompt When showmode is disabled (e.g. in screen), do not display the mode in PS1. * (2012-07-08) Mikael Berthe Add development prompt (HG and minimal git support) Can be set up from the shell command line with "prompt_set_dev". * (2012-07-08) Mikael Berthe Ignore Vim swap files * (2009-12-22) Mikael Berthe Slight update zlog{in,out} * (2009-12-22) Mikael Berthe Add zlogin * (2009-12-22) Mikael Berthe Update hgignore list * (2009-12-22) Mikael Berthe Initial import into Mercurial
.hgignore
.zshrc
functions/zshrc_vcsinfo
tools/git-prompt.sh
zlogin
zlogout
zsh_local/.placeholder
zshenv
zshrc
zshrc.d/20-prompt.zrc
zshrc.d/30-aliases.zrc
zshrc.d/30-functions.zrc
zshrc.d/50-local.zrc
zshrc.d/60-vi-showmode.zrc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Sat Jul 14 19:20:57 2012 +0200
@@ -0,0 +1,5 @@
+syntax: glob
+
+.zcompdump
+zsh_local/*
+*.sw[po]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.zshrc	Sat Jul 14 19:20:57 2012 +0200
@@ -0,0 +1,2 @@
+
+source $ZDOTDIR/zshrc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/functions/zshrc_vcsinfo	Sat Jul 14 19:20:57 2012 +0200
@@ -0,0 +1,165 @@
+#
+# MiKael, 2012-07-10
+# Sources:
+#   https://github.com/whiteinge/dotfiles/blob/master/.zsh_shouse_prompt
+#   http://git.rolinh.ch/index.php?p=dotfiles.git
+
+# {{{
+
+autoload -Uz vcs_info
+
+zstyle ':vcs_info:*' enable git hg
+zstyle ':vcs_info:(hg*|git*):*' get-revision true
+zstyle ':vcs_info:(hg*|git*):*' check-for-changes true
+
+zstyle ':vcs_info:hg*' formats "(%B%s%{${reset_color}%})[%i%u %b %m]" # rev+changes branch misc
+#zstyle ':vcs_info:hg*' actionformats "(%s|%{$fg[red]%}%a%{$fg[white]%})[%i%u %b %m]"
+zstyle ':vcs_info:hg*' actionformats "%{$fg[red]%}%a %{${reset_color}%}[%i%u %{$fg[blue]%}%b%{${reset_color}%}%m]"
+
+zstyle ':vcs_info:hg*:*' get-bookmarks true
+zstyle ':vcs_info:hg*:*' get-mq true
+
+zstyle ':vcs_info:hg*:*' get-unapplied true
+zstyle ':vcs_info:hg*:*' patch-format "mq(%g):%n/%c %p"
+zstyle ':vcs_info:hg*:*' nopatch-format "mq(%g):%n/%c %p"
+
+zstyle ':vcs_info:hg*:*' unstagedstr "%{$fg_bold[red]%}+%{${reset_color}%}"
+zstyle ':vcs_info:hg*:*' hgrevformat "%r" # only show local rev.
+zstyle ':vcs_info:hg*:*' branchformat "%b" # only show branch
+
+zstyle ':vcs_info:git*' formats "(%B%s%{${reset_color}%}) %12.12i %c%u %b%m" # hash changes branch misc
+#zstyle ':vcs_info:git*' formats "%c%u %b%m" # hash changes branch misc
+zstyle ':vcs_info:git*' actionformats "(%s|%{$fg[white]%}%a) %12.12i %c%u %b%m"
+
+zstyle ':vcs_info:git*:*' stagedstr "%{$fg[green]%}S%{${reset_color}%}"
+zstyle ':vcs_info:git*:*' unstagedstr "%{$fg[red]%}U%{${reset_color}%}"
+
+# zstyle ':vcs_info:hg:*:-all-' command fakehg
+# zstyle ':vcs_info:*+*:*' debug true
+
+zstyle ':vcs_info:hg*+set-hgrev-format:*' hooks hg-hashfallback
+zstyle ':vcs_info:hg*+set-message:*' hooks mq-vcs
+#zstyle ':vcs_info:git*+set-message:*' hooks git-st git-stash
+zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-st
+
+### Dynamically set hgrevformat based on if the local rev is available
+# We don't always know the local revision, e.g. if use-simple is set
+# Truncate long hash to 12-chars but also allow for multiple parents
+function +vi-hg-hashfallback() {
+    if [[ -z ${hook_com[localrev]} ]] ; then
+        local -a parents
+
+        parents=( ${(s:+:)hook_com[hash]} )
+        parents=( ${(@r:12:)parents} )
+        hook_com[rev-replace]="${(j:+:)parents}"
+
+        ret=1
+    fi
+}
+
+### Show when mq itself is under version control
+function +vi-mq-vcs() {
+    # if [[ -d ${hook_com[base]}/.hg/patches/.hg ]]; then
+        # hook_com[hg-mqpatch-string]="mq:${hook_com[hg-mqpatch-string]}"
+    # fi
+}
+
+# Show remote ref name and number of commits ahead-of or behind
+function +vi-git-st() {
+    local ahead behind remote
+    local -a gitstatus
+
+    # Are we on a remote-tracking branch?
+    remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} \
+        --symbolic-full-name --abbrev-ref 2>/dev/null)}
+
+    if [[ -n ${remote} ]] ; then
+        # for git prior to 1.7
+        # ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l)
+        ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
+        (( $ahead )) && gitstatus+=( "%{$fg[green]%}+${ahead}%{${reset_color}%}" )
+
+        # for git prior to 1.7
+        # behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l)
+        behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
+        (( $behind )) && gitstatus+=( "%{$fg[red]%}-${behind}%{${reset_color}%}" )
+
+        #hook_com[branch]="${hook_com[branch]} [${remote} ${(j:/:)gitstatus}]"
+        hook_com[branch]="[%{$fg[blue]%}${hook_com[branch]}%{${reset_color}%}]"
+    fi
+}
+
+# Show count of stashed changes
+function +vi-git-stash() {
+    local -a stashes
+
+    if [[ -s ${hook_com[base]}/.git/refs/stash ]] ; then
+        stashes=$(git stash list 2>/dev/null | wc -l)
+        #hook_com[misc]+=" (${stashes} stashed)"
+        hook_com[misc]+="(%{$fg[red]%}${stashes} %{${reset_color}%}stashed)"
+    fi
+}
+
+# Show count of untracked files
+function +vi-git-untracked(){
+	if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \
+		git status --porcelain | grep '??' &> /dev/null ; then
+		# This will show the marker if there are any untracked files in repo.
+		# If instead you want to show the marker only if there are untracked
+		# files in $PWD, use:
+		#[[ -n $(git ls-files --others --exclude-standard) ]] ; then
+		local nb_untracked=$(git status --porcelain | grep "\? \?" | wc -l)
+		local nb_up=$(git status --porcelain | grep "M" | wc -l)
+		hook_com[staged]+="%{${reset_color}%}$nb_untracked%{$fg[red]%}N %{${reset_color}%}$nb_up"
+	fi
+}
+
+# }}}
+
+# {{{ Prompts
+
+setopt transient_rprompt
+
+# Others prompts
+PS2="%{$fg_no_bold[yellow]%}%_>%{${reset_color}%} "
+PS3="%{$fg_no_bold[yellow]%}?#%{${reset_color}%} "
+
+# }}}
+
+# {{{ precmd()
+
+function __precmd_vcsinfo {
+
+  vcs_info
+
+  local deco="%{${fg_no_bold[white]}%}"
+
+  if [[ -O "$PWD" ]]; then
+    local path_color="${fg_no_bold[magenta]}"
+  elif [[ -w "$PWD" ]]; then
+    local path_color="${fg_no_bold[blue]}"
+  else
+    local path_color="${fg_bold[red]}"
+  fi
+
+  if [[ $UID -eq 0 ]]; then
+    local user_color="${fg_bold[red]}"
+  else
+    local user_color="${fg_bold[default]}"
+  fi
+
+  local return_code="%(?..${deco}!%{${fg_bold[red]}%}%?${deco}! %{${reset_color}%})"
+  #local cwd="%{${path_color}%}%32<...<%~"
+  local cwd="%{${path_color}%}%~%{${reset_color}%}"
+  local sign="%(!.%{${fg_bold[red]}%}.${deco})%#"
+
+  PS1="${cwd}
+${return_code}%D{%m%d %H:%M} [%B%n%b] %{%{$fg[red]%}%}%m%{${reset_color}%}${sign}%{${reset_color}%} "
+
+  # Prompt on the right, displayed when in a VCS repository
+  RPS1="${vcs_info_msg_0_}%{${reset_color}%}"
+
+  setopt prompt_subst
+}
+
+# }}}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/git-prompt.sh	Sat Jul 14 19:20:57 2012 +0200
@@ -0,0 +1,289 @@
+# bash/zsh git prompt support
+#
+# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
+# Distributed under the GNU General Public License, version 2.0.
+#
+# This script allows you to see the current branch in your prompt.
+#
+# To enable:
+#
+#    1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).
+#    2) Add the following line to your .bashrc/.zshrc:
+#        source ~/.git-prompt.sh
+#    3) Change your PS1 to also show the current branch:
+#         Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
+#         ZSH:  PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
+#
+# The argument to __git_ps1 will be displayed only if you are currently
+# in a git repository.  The %s token will be the name of the current
+# branch.
+#
+# In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value,
+# unstaged (*) and staged (+) changes will be shown next to the branch
+# name.  You can configure this per-repository with the
+# bash.showDirtyState variable, which defaults to true once
+# GIT_PS1_SHOWDIRTYSTATE is enabled.
+#
+# You can also see if currently something is stashed, by setting
+# GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
+# then a '$' will be shown next to the branch name.
+#
+# If you would like to see if there're untracked files, then you can set
+# GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're untracked
+# files, then a '%' will be shown next to the branch name.
+#
+# If you would like to see the difference between HEAD and its upstream,
+# set GIT_PS1_SHOWUPSTREAM="auto".  A "<" indicates you are behind, ">"
+# indicates you are ahead, and "<>" indicates you have diverged.  You
+# can further control behaviour by setting GIT_PS1_SHOWUPSTREAM to a
+# space-separated list of values:
+#
+#     verbose       show number of commits ahead/behind (+/-) upstream
+#     legacy        don't use the '--count' option available in recent
+#                   versions of git-rev-list
+#     git           always compare HEAD to @{upstream}
+#     svn           always compare HEAD to your SVN upstream
+#
+# By default, __git_ps1 will compare HEAD to your SVN upstream if it can
+# find one, or @{upstream} otherwise.  Once you have set
+# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
+# setting the bash.showUpstream config variable.
+
+# __gitdir accepts 0 or 1 arguments (i.e., location)
+# returns location of .git repo
+__gitdir ()
+{
+	# Note: this function is duplicated in git-completion.bash
+	# When updating it, make sure you update the other one to match.
+	if [ -z "${1-}" ]; then
+		if [ -n "${__git_dir-}" ]; then
+			echo "$__git_dir"
+		elif [ -n "${GIT_DIR-}" ]; then
+			test -d "${GIT_DIR-}" || return 1
+			echo "$GIT_DIR"
+		elif [ -d .git ]; then
+			echo .git
+		else
+			git rev-parse --git-dir 2>/dev/null
+		fi
+	elif [ -d "$1/.git" ]; then
+		echo "$1/.git"
+	else
+		echo "$1"
+	fi
+}
+
+# stores the divergence from upstream in $p
+# used by GIT_PS1_SHOWUPSTREAM
+__git_ps1_show_upstream ()
+{
+	local key value
+	local svn_remote svn_url_pattern count n
+	local upstream=git legacy="" verbose=""
+
+	svn_remote=()
+	# get some config options from git-config
+	local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')"
+	while read -r key value; do
+		case "$key" in
+		bash.showupstream)
+			GIT_PS1_SHOWUPSTREAM="$value"
+			if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
+				p=""
+				return
+			fi
+			;;
+		svn-remote.*.url)
+			svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value"
+			svn_url_pattern+="\\|$value"
+			upstream=svn+git # default upstream is SVN if available, else git
+			;;
+		esac
+	done <<< "$output"
+
+	# parse configuration values
+	for option in ${GIT_PS1_SHOWUPSTREAM}; do
+		case "$option" in
+		git|svn) upstream="$option" ;;
+		verbose) verbose=1 ;;
+		legacy)  legacy=1  ;;
+		esac
+	done
+
+	# Find our upstream
+	case "$upstream" in
+	git)    upstream="@{upstream}" ;;
+	svn*)
+		# get the upstream from the "git-svn-id: ..." in a commit message
+		# (git-svn uses essentially the same procedure internally)
+		local svn_upstream=($(git log --first-parent -1 \
+					--grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null))
+		if [[ 0 -ne ${#svn_upstream[@]} ]]; then
+			svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}
+			svn_upstream=${svn_upstream%@*}
+			local n_stop="${#svn_remote[@]}"
+			for ((n=1; n <= n_stop; n++)); do
+				svn_upstream=${svn_upstream#${svn_remote[$n]}}
+			done
+
+			if [[ -z "$svn_upstream" ]]; then
+				# default branch name for checkouts with no layout:
+				upstream=${GIT_SVN_ID:-git-svn}
+			else
+				upstream=${svn_upstream#/}
+			fi
+		elif [[ "svn+git" = "$upstream" ]]; then
+			upstream="@{upstream}"
+		fi
+		;;
+	esac
+
+	# Find how many commits we are ahead/behind our upstream
+	if [[ -z "$legacy" ]]; then
+		count="$(git rev-list --count --left-right \
+				"$upstream"...HEAD 2>/dev/null)"
+	else
+		# produce equivalent output to --count for older versions of git
+		local commits
+		if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)"
+		then
+			local commit behind=0 ahead=0
+			for commit in $commits
+			do
+				case "$commit" in
+				"<"*) ((behind++)) ;;
+				*)    ((ahead++))  ;;
+				esac
+			done
+			count="$behind	$ahead"
+		else
+			count=""
+		fi
+	fi
+
+	# calculate the result
+	if [[ -z "$verbose" ]]; then
+		case "$count" in
+		"") # no upstream
+			p="" ;;
+		"0	0") # equal to upstream
+			p="=" ;;
+		"0	"*) # ahead of upstream
+			p=">" ;;
+		*"	0") # behind upstream
+			p="<" ;;
+		*)	    # diverged from upstream
+			p="<>" ;;
+		esac
+	else
+		case "$count" in
+		"") # no upstream
+			p="" ;;
+		"0	0") # equal to upstream
+			p=" u=" ;;
+		"0	"*) # ahead of upstream
+			p=" u+${count#0	}" ;;
+		*"	0") # behind upstream
+			p=" u-${count%	0}" ;;
+		*)	    # diverged from upstream
+			p=" u+${count#*	}-${count%	*}" ;;
+		esac
+	fi
+
+}
+
+
+# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
+# returns text to add to bash PS1 prompt (includes branch name)
+__git_ps1 ()
+{
+	local g="$(__gitdir)"
+	if [ -n "$g" ]; then
+		local r=""
+		local b=""
+		if [ -f "$g/rebase-merge/interactive" ]; then
+			r="|REBASE-i"
+			b="$(cat "$g/rebase-merge/head-name")"
+		elif [ -d "$g/rebase-merge" ]; then
+			r="|REBASE-m"
+			b="$(cat "$g/rebase-merge/head-name")"
+		else
+			if [ -d "$g/rebase-apply" ]; then
+				if [ -f "$g/rebase-apply/rebasing" ]; then
+					r="|REBASE"
+				elif [ -f "$g/rebase-apply/applying" ]; then
+					r="|AM"
+				else
+					r="|AM/REBASE"
+				fi
+			elif [ -f "$g/MERGE_HEAD" ]; then
+				r="|MERGING"
+			elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
+				r="|CHERRY-PICKING"
+			elif [ -f "$g/BISECT_LOG" ]; then
+				r="|BISECTING"
+			fi
+
+			b="$(git symbolic-ref HEAD 2>/dev/null)" || {
+
+				b="$(
+				case "${GIT_PS1_DESCRIBE_STYLE-}" in
+				(contains)
+					git describe --contains HEAD ;;
+				(branch)
+					git describe --contains --all HEAD ;;
+				(describe)
+					git describe HEAD ;;
+				(* | default)
+					git describe --tags --exact-match HEAD ;;
+				esac 2>/dev/null)" ||
+
+				b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
+				b="unknown"
+				b="($b)"
+			}
+		fi
+
+		local w=""
+		local i=""
+		local s=""
+		local u=""
+		local c=""
+		local p=""
+
+		if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
+			if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
+				c="BARE:"
+			else
+				b="GIT_DIR!"
+			fi
+		elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
+			if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
+				if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
+					git diff --no-ext-diff --quiet --exit-code || w="*"
+					if git rev-parse --quiet --verify HEAD >/dev/null; then
+						git diff-index --cached --quiet HEAD -- || i="+"
+					else
+						i="#"
+					fi
+				fi
+			fi
+			if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
+				git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
+			fi
+
+			if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
+				if [ -n "$(git ls-files --others --exclude-standard)" ]; then
+					u="%"
+				fi
+			fi
+
+			if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
+				__git_ps1_show_upstream
+			fi
+		fi
+
+		local f="$w$i$s$u"
+		printf -- "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
+	fi
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zlogin	Sat Jul 14 19:20:57 2012 +0200
@@ -0,0 +1,3 @@
+#
+
+[ -f $ZDOTLOCALDIR/zlogin ] && . $ZDOTLOCALDIR/zlogin
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zlogout	Sat Jul 14 19:20:57 2012 +0200
@@ -0,0 +1,4 @@
+#
+
+clear
+[ -f $ZDOTLOCALDIR/zlogout ] && . $ZDOTLOCALDIR/zlogout
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zshenv	Sat Jul 14 19:20:57 2012 +0200
@@ -0,0 +1,44 @@
+#
+# This file is sourced on all invocations of the shell.
+# If the -f flag is present or if the NO_RCS option is
+# set within this file, all other initialization files
+# are skipped.
+#
+# This file should contain commands to set the command
+# search path, plus other important environment variables.
+# This file should not contain commands that produce
+# output or assume the shell is attached to a tty.
+#
+# Global Order: zshenv, zprofile, zshrc, zlogin
+
+export ZDOTLOCALDIR=$ZDOTDIR/zsh_local
+
+# PATH
+PATH="$HOME/bin:/usr/local/bin:/usr/bin:/bin:/usr/games"
+# Correction du PATH pour root
+# Essentiel si l'utilisateur est connecte en non-root puis fait un 'su -'
+# par defaut les repertoires /sbin, /usr/sbin, /usr/local/sbin manquent.
+if [[ $UID -eq 0 ]]; then
+  PATH="/usr/local/sbin:/usr/sbin:/sbin:${PATH}"
+fi
+export PATH
+
+# Options de 'less'
+export LESS="-Mi"
+# Ouvre les fichiers compressés
+eval $(lesspipe)
+
+# Pager
+export PAGER=less
+export MANPAGER=less
+
+watch=(notme)
+WATCHFMT='%n %a %l from %m at %T on %D.'
+
+REPORTTIME=60
+
+# Bip visuel
+export ZBEEP='\e[?5h\e[?5l'
+
+export EDITOR='vim'
+export VISUAL=$EDITOR
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zshrc	Sat Jul 14 19:20:57 2012 +0200
@@ -0,0 +1,304 @@
+#
+# This file is sourced only for interactive shells. It
+# should contain commands to set up aliases, functions,
+# options, key bindings, etc.
+#
+# Global Order: zshenv, zprofile, zshrc, zlogin
+
+# Copyright (c) 1995 Antoine VOUILLON
+# Copyright (c) 1995-1999 Farzad FARID
+# Copyright (c) Mikael BERTHE, 2001-2012
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+# La ligne suivante provoque parfois un message d'erreur non gênant
+unalias run-help 2>/dev/null
+autoload run-help
+
+autoload -U zmv
+
+# Protection des fichiers    : rw-rw-r--
+# Protection des répertoires : rwxrwxr-x
+if [[ $UID -eq 0 ]]; then
+  umask 022
+else
+  umask 002
+fi
+
+ulimit -c 0
+# Pas de limite pour les coredump
+#ulimit -c unlimited
+#unlimit coredumpsize
+
+########################
+# Definition du prompt #
+########################
+
+# Chargement des variables pour les couleurs
+autoload colors; colors;
+
+# Prompt complet (date, login, tty, hostname, cwd) sur une ligne
+# (Invite de commande de secours...)
+export PS1="%T %B[%n:%l]%b %S%m%s:%~%# "
+
+# Prompt complet sur 2 lignes, N&B
+#export PS1="%B%~%b
+#%D{%m%d %H:%M} %B[%n:%l]%b %S%m%s%# "
+
+export PS2='%_.. > '
+
+# Enable my Vim-like mode for supported terms
+if [[ "$TERM" == "rxvt" ||
+      "$TERM" == "rxvt-256color" ||
+      "$TERM" == "rxvt-unicode" ||
+      "$TERM" == "rxvt-unicode-256color" ]]
+then
+    export SHOWMODE="on"
+fi
+
+set shell=$SHELL
+#cdpath=(~)
+
+if [[ -z "$FPATH" ]]; then
+  if [[ -d "/usr/lib/zsh/functions" ]]; then
+    FPATH="/usr/lib/zsh/functions"
+  elif [[ -d "/usr/share/zsh/functions" ]]; then
+    FPATH="/usr/share/zsh/functions"
+  else
+    echo "zsh: Could not set FPATH variable: no ../zsh/functions directory"
+  fi
+fi
+
+# Pour configurer les couleurs créer le fichier /etc/LS_COLORS avec la
+# commande "dircolors --print-database > /etc/LS_COLORS" et l'éditer.
+# Taper 'man dircolors' pour plus de details
+if [[ -x /usr/bin/dircolors ]]; then
+  if [[ -e /etc/LS_COLORS ]]; then
+    eval $(dircolors -b /etc/LS_COLORS)
+  else
+    eval $(dircolors -b)
+  fi
+  LS_OPTIONS=(--color=auto)
+  export LS_OPTIONS
+fi
+
+
+####################
+# Options du shell #
+####################
+
+# Les noms des options sont écrits avec le souligné '_' optionnel pour
+# faciliter la recherche dans la documentation de zsh.
+
+# Options de completion. Complète les noms de commandes/fichiers avec TAB
+# listes toutes les possibilités, ne beep pas, boucle entre les choix par
+# appui répété sur TAB.
+#setopt menu_complete
+setopt auto_list
+setopt list_types
+setopt no_list_beep
+#setopt bash_auto_list
+
+# Correction automatique
+setopt correct
+unsetopt correct_all
+
+# Autres options
+
+# chdir « intelligent »
+setopt auto_cd
+
+# On ne modifie pas des fichiers existants avec '>' et '>>'
+setopt no_clobber
+
+unsetopt bg_nice
+setopt no_flow_control
+setopt no_hup
+unsetopt sun_keyboard_hack
+
+# On n'écrase pas le fichier d'historique
+setopt append_history
+# On autorise les commentaires
+setopt interactive_comments
+# Les lignes commençant par une espace ne seront pas archivées
+setopt hist_ignore_space
+# fc -l ne sera pas archivé
+setopt hist_no_store
+# Pas de doublons dans  l'historique
+setopt hist_ignore_dups
+# Les répertoires sont automatiquement mis dans la pile (cf. pushd, popd...)
+setopt auto_pushd
+# ... sans doublons
+setopt pushd_ignore_dups
+# Affiche la valeur de retour d'un programme (si non nulle)
+setopt print_exit_value
+# Essaie de réduire la liste des complétions
+setopt list_packed
+
+#setopt nobeep
+
+
+############################
+# Historique des commandes #
+############################
+
+export SAVEHIST=4096
+export HISTSIZE=4096
+export HIST_EXPIRE_DUPS_FIRST
+export HISTFILE=$HOME/.history
+
+
+#############################
+# Configuration des touches #
+#############################
+
+# Pour que la touche Alt marche dans les xterm
+bindkey -e
+if [[ -z ${TERM:#xterm*} || -z ${TERM:#rxvt*} || -z ${TERM:#linux*} ]]; then
+  stty pass8
+  # L'option -m empêche l'utilisation des accents (è = ESC-h, etc.)
+  #bindkey -me
+fi
+
+# Universelle
+#bindkey '^Q'    quoted-insert
+bindkey '[2~' overwrite-mode                    # Ins
+bindkey '[3~' delete-char                       # Suppr
+bindkey '[5~' history-beginning-search-backward # PgUp
+bindkey '[6~' history-beginning-search-forward  # PgDn
+bindkey '^[^I'  reverse-menu-complete             # ESC-Tab
+bindkey '^Xc'   copy-prev-word
+bindkey '^Xf'   _correct_filename
+bindkey '^Xm'   _most_recent_file
+
+
+# Sur la console
+if [[ "$TERM" == "console" || "$TERM" == "vt100" ]]; then
+  bindkey '^[[1~' beginning-of-line       # Home
+  bindkey '^[[4~' end-of-line             # End
+fi
+
+# Dans un xterm term=linux
+if [[ -z ${TERM:#linux*} || -z ${TERM:#screen} ]]; then
+  bindkey '^[[H'  beginning-of-line       # Home
+  bindkey '^[[F'  end-of-line             # End
+  bindkey '[1~'  beginning-of-line       # Home
+  bindkey '[4~'  end-of-line             # End
+fi
+
+# Dans un xterm
+if [[ -z ${TERM:#xterm*} ]]; then
+  bindkey '^[[H'  beginning-of-line       # Home
+  bindkey '^[[F'  end-of-line             # End
+  bindkey '[1~'  beginning-of-line       # Home
+  bindkey '[4~'  end-of-line             # End
+fi
+
+# Dans un rxvt
+if [[ -z ${TERM:#rxvt*} ]]; then
+  bindkey '^[[7~' beginning-of-line       # Home
+  bindkey '^[[8~' end-of-line             # End
+fi
+
+# Sur un xterm, on differencie backspace et delete (?).
+if [[ -z ${TERM:#xterm*} ]]
+then
+  bindkey '^H'  backward-delete-char    # Backspace
+  bindkey '^?'  backward-delete-char    # Backspace
+fi
+
+# En combinaison avec le "keycode 22 = Backspace" du .Xmodmap pour
+# faire marcher le backspace dans Netscape
+stty erase '^?'
+
+#######################################################
+# Completion, lire le man pour plus de renseignements #
+#######################################################
+
+#compctl -g '*(-/)' cd pushd
+compctl -g '.*(-/) *(-/)' cd pushd
+compctl -g '.*(-/) *(-/)' rmdir
+compctl -g '*.Z *.z *.gz *.tgz *(-/)' zcat gunzip
+compctl -g '*.Z *.z *.gz *.tgz *.tar *.bz2 *(-/)' tart tarx tar
+compctl -g '*.bz2 *(-/)' bz2cat bunzip2
+compctl -g '*.zip *.ZIP *.exe *.EXE *(-/)' unzip
+compctl -g '*.ps *.ps.gz *(-/)' gs ghostview gv evince
+compctl -g '*.tex* *.latex* *(-/)' tex latex texi2dvi
+compctl -g '*.dvi *(-/)' xdvi dvips
+compctl -j -P % -x 's[-] p[1]' -k signals -- kill
+compctl -l '' nohup exec
+compctl -u -x 's[@]' -k hosts -- finger
+compctl -m info
+compctl -m -g '*.1 *(-/)' man
+compctl -c which where type
+compctl -g '*.pdf *(-/)' evince
+
+# Hosts completion
+
+if [ -f ~/.ssh/config ]; then
+  hosts=($hosts `grep ^Host ~/.ssh/config | sed s/Host\ // | egrep -v '^\*$'`)
+fi
+if [ "$hosts" ]; then
+  zstyle ':completion:*:hosts' hosts $hosts
+fi
+
+##########
+# zstyle #
+##########
+
+zstyle ':completion:*' completer _expand _complete _correct _approximate
+zstyle ':completion:*' completions 1
+zstyle ':completion:*' format 'Completing %B%d%b%:'
+zstyle ':completion:*' glob 1
+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:*' max-errors 2 numeric
+zstyle ':completion:*' menu select=3
+zstyle ':completion:*' prompt '%e erreur(s)...'
+zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
+zstyle ':completion:*' substitute 1
+
+autoload -Uz compinit
+compinit
+
+# Needed for menuselect below
+zmodload zsh/complist
+
+autoload -U incremental-complete-word
+zle -N incremental-complete-word
+bindkey 'i' incremental-complete-word
+
+bindkey -M menuselect '' accept-and-infer-next-history
+
+bindkey -s '' '/'
+bindkey -s '' ','
+
+
+##############################
+# Source configuration files #
+##############################
+
+for rc in $ZDOTDIR/zshrc.d/??-*.zrc; do
+    [[ -r ${rc} ]] && source "$rc"
+done
+unset rc
+
+# Local configuration files
+# (Other that zshrc, which is sourced from our zshrc.d scripts)
+localrcfiles=($ZDOTLOCALDIR/??-*.zrc) 2> /dev/null
+for rc in $localrcfiles; do
+    [[ -r ${rc} ]] && source "$rc"
+done
+unset rc localrcfiles
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zshrc.d/20-prompt.zrc	Sat Jul 14 19:20:57 2012 +0200
@@ -0,0 +1,159 @@
+
+# You can use fast_hg_root from https://bitbucket.org/yaniv_aknin/fast_hg_root
+# or maybe use the command false if you don't use Mercurial at all.
+# (Override in $ZDOTLOCALDIR/zshrc)
+HG_ROOT_CMD=("hg" "root")
+export HG_ROOT_CMD
+
+
+### Extended prompts
+
+function __prompt_path_color {
+  local path_color
+  if [[ -O "$PWD" ]]; then
+    path_color="${fg_no_bold[magenta]}"
+  elif [[ -w "$PWD" ]]; then
+    path_color="${fg_no_bold[blue]}"
+  else
+    path_color="${fg_bold[red]}"
+  fi
+  print "%{$path_color%}"
+}
+
+# From http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
+function __prompt_char {
+    __gitdir >/dev/null 2>/dev/null && echo '±' && return
+    $HG_ROOT_CMD >/dev/null 2>/dev/null && echo '☿' && return
+    echo '○'
+}
+
+function __hg_prompt_info {
+    $HG_ROOT_CMD >/dev/null 2>/dev/null && 
+    hg prompt --angle-brackets "
+<HG patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg[cyan]%})|post_unapplied(%{$reset_color%})>
+>%BHG%b<(%{$fg[green]%}<status|modified|unknown>%{$reset_color%})><%{$fg[green]%}<update>%{$reset_color%}>\
+< on %{$fg[magenta]%}<branch|quiet>%{$reset_color%}>\
+< at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>" 2>/dev/null
+}
+
+source $ZDOTDIR/tools/git-prompt.sh > /dev/null 2>&1
+function __git_prompt_info {
+  r=$(__git_ps1)
+  if [ ! -z $r ]; then echo -e "\n%Bgit%b$r"; fi
+}
+
+function __prompt_set_dev {
+    # Prompt complet sur 2 lignes, couleurs, avec un indicateur de dépôt git/hg
+    local -a lines pline
+
+    local red="%{$fg[red]%}"
+    local cyan="%{$fg[cyan]%}"
+    local reset="%{$reset_color%}"
+
+    # 1re ligne
+    pline+=( "%D{%m%d} " )              # Date
+    pline+=( "$cyan%D{%H:%M}$reset " )  # Time
+    pline+=( $(__prompt_path_color) )   # Couleur du chemin dynamique
+    pline+=( "%~$reset" )               # Chemin (cwd)
+    lines+=( ${(j::)pline} )
+    pline=()
+
+    # 2e ligne
+    pline+=( "[%B%n%b] " )              # Nom d'utilisateur
+    pline+=( "$red%m$reset" )           # Nom de machine
+    pline+=( $(__prompt_char) )         # Indicateur de dépôt (hg/git)
+    pline+=( "%# " )                    # Invite de commande
+    lines+=( ${(j::)pline} )
+
+    export PS1=${(F)lines}
+}
+
+function __prompt_set_dev-mikael {
+    # Prompt complet sur 2 ou 3 lignes, avec informations sur les dépôts git/hg
+    local -a lines pline
+
+    local red="%{$fg[red]%}"
+    local cyan="%{$fg[cyan]%}"
+    local reset="%{$reset_color%}"
+
+    # 1re ligne
+    pline+=( "%D{%m%d} " )              # Date
+    pline+=( "$cyan%D{%H:%M}$reset " )  # Time
+    pline+=( $(__prompt_path_color) )   # Couleur du chemin dynamique
+    pline+=( "%~$reset" )               # Chemin (cwd)
+    lines+=( ${(j::)pline} )
+    pline=()
+
+    # 2e ligne
+    pline+=( "[%B%n%b] " )              # Nom d'utilisateur
+    pline+=( "$red%m$reset" )           # Nom de machine
+    pline+=( "$(__hg_prompt_info)" )    # Informations de dépôt Mercurial
+    pline+=( "$(__git_prompt_info)" )   # Informations de dépôt git
+    pline+=( "%# " )                    # Invite de commande
+    lines+=( ${(j::)pline} )
+
+    export PS1=${(F)lines}
+}
+
+function precmd {
+    case $_PROMPT_DEFINED in
+        dev)
+            __prompt_set_dev
+            ;;
+        dev-mikael)
+            __prompt_set_dev-mikael
+            ;;
+        dev-vcsinfo)
+            __precmd_vcsinfo
+            ;;
+        esac
+}
+
+function prompt_set_dev-vcsinfo {
+    _PROMPT_DEFINED="dev-vcsinfo"
+    source $ZDOTDIR/functions/zshrc_vcsinfo
+}
+
+function __prompt_unset_dev-vcsinfo {
+    if [[ $_PROMPT_DEFINED == "dev-vcsinfo" ]]; then
+        zstyle ':vcs_info:*' enable NONE
+        unset RPS1
+    fi
+}
+
+function prompt_set_blackwhite {
+    # Prompt complet sur 2 lignes, N&B
+    __prompt_unset_dev-vcsinfo
+    unsetopt prompt_subst
+
+    export PS1="%D{%m%d %H:%M} %B%~%b
+[%B%n%b:%l] %S%m%s%# "
+
+    export _PROMPT_DEFINED="blackwhite"
+}
+
+function prompt_set_color {
+    # Prompt complet sur 2 lignes, couleurs
+    __prompt_unset_dev-vcsinfo
+    unsetopt prompt_subst
+
+    PS1="%D{%m%d} %{$fg[cyan]%}%D{%H:%M}%{$reset_color%} "
+    PS1=$PS1"%{$fg[magenta]%}%~%{$reset_color%}
+[%B%n%b:%l] %{$fg[red]%}%m%{$reset_color%}%# "
+    export PS1
+
+    export _PROMPT_DEFINED="blackwhite"
+}
+
+function prompt_set_dev {
+    __prompt_unset_dev-vcsinfo
+    export _PROMPT_DEFINED="dev"
+}
+function prompt_set_dev-mikael {
+    __prompt_unset_dev-vcsinfo
+    export _PROMPT_DEFINED="dev-mikael"
+}
+
+
+# Invite de commande par défaut
+prompt_set_color
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zshrc.d/30-aliases.zrc	Sat Jul 14 19:20:57 2012 +0200
@@ -0,0 +1,67 @@
+
+###########
+# Aliases #
+###########
+
+# Ces 3 alias demandent confirmation avant d'ecraser un fichier
+alias cp='cp -i'
+alias mv='mv -i'
+alias rm='rm -i'
+
+alias cd..='cd ..'
+
+# Gestion de l'historique des commandes
+alias h=history 23
+alias H='history | less'
+
+# Affiche la liste de tous les processus tournant en memoire
+alias psx='ps aux | less -S'
+
+# Affiche la liste de tous vos processus
+alias psu='ps ux | less -S'
+
+# Divers alias pour lister le contenu d'un repertoire
+# la = comme 'ls' avec les fichiers caches en plus
+# ll = tout lister, y compris les fichiers caches
+# lm = comme 'll' avec une pause en plus
+# dir = affichage long
+# dirm = comme 'dirm' avec une pause en plus
+alias l='command ls $LS_OPTIONS -l'
+alias ls='command ls $LS_OPTIONS -F'
+alias la='command ls $LS_OPTIONS -aF'
+alias ll='command ls $LS_OPTIONS -laF'
+function lm() { command ls $LS_OPTIONS -laF $* | less }
+alias dir='command ls $LS_OPTIONS -lF'
+function dirm() { command ls $LS_OPTIONS -lF $* | less }
+
+# Gestion de la directory stack, lire le man pour en savoir plus
+alias d=dirs
+alias dv='dirs -v'
+#alias pu=pushd
+#alias po=popd
+
+if [[ -x /usr/bin/xemacs ]]; then
+  alias em='xemacs -nw'
+elif [[ -x /usr/bin/emacs ]]; then
+  alias em='emacs -nw'
+fi
+if [[ -x /usr/bin/vim ]]; then
+  alias vi=vim
+fi
+
+# DNS stuff
+alias dmx='dig -t MX +nocmd +nocomment +identify +nostats +noquestion'
+alias dhost='dig +nocmd +nocomment +identify +nostats +noquestion'
+
+# :)
+alias :q='echo "Ha ha ha :-)"'
+
+# Xterm resizing-fu  (From Joey...)
+alias default='echo -e "\033]50;fixed\007"'
+alias normal=default
+#alias hide='echo -e "\033]50;nil2\007"'
+#alias tiny='echo -e "\033]50;5x7\007"'
+alias small='echo -e "\033]50;6x10\007"'
+alias medium='echo -e "\033]50;7x13\007"'
+alias large='echo -e "\033]50;9x15\007"'
+alias huge='echo -e "\033]50;10x20\007"'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zshrc.d/30-functions.zrc	Sat Jul 14 19:20:57 2012 +0200
@@ -0,0 +1,97 @@
+
+#############
+# Functions #
+#############
+
+# Commande tres pratique pour formatter un fichier .man
+# exemple : mf prog.1
+function mf() { tbl $* | nroff -mandoc | less -s }
+
+# ,,(), ,,,() for quickly changing $CWD {{{1
+# http://www.shell-fu.org/lister.php?id=769
+
+# Go up n levels:
+# ,, 3
+function ,, (){
+    local arg=${1:-1};
+    local dir=""
+    while [ $arg -gt 0 ]; do
+        dir="../$dir"
+        arg=$(($arg - 1));
+    done
+    cd $dir >&/dev/null
+}
+
+# Go up to a named dir
+# ,,, usr
+function ,,, (){
+    if [ -z "$1" ]; then
+        return
+    fi
+    local maxlvl=16
+    local dir=$1
+    while [ $maxlvl -gt 0 ]; do
+        dir="../$dir"
+        maxlvl=$(($maxlvl - 1));
+        if [ -d "$dir" ]; then
+            cd $dir >&/dev/null
+        fi
+    done
+}
+
+
+# Customized version from Frank Terbeck' scripts
+# http://bewatermyfriend.org/p/2011/013/
+# "."   will display the current working directory
+# ".."  will get you 1 directory up,
+# "..." will get you 2 directories up, etc.
+function ft_accept_line_cd_up() {
+    setopt local_options extended_glob
+    local -a cmdline
+    cmdline=( ${(z)BUFFER} )
+    if (( ${#cmdline} == 1 )) && [[ ${cmdline[1]} == "." ]] ; then
+        BUFFER="pwd"
+        zle ".$WIDGET"
+        return
+    fi
+    if (( ${#cmdline} == 1 )) && [[ ${cmdline[1]} == ..## ]] ; then
+        BUFFER='cd '
+        for (( i = 2; i <= ${#${cmdline[1]}}; i++ )); do
+            BUFFER="${BUFFER}../"
+        done
+        BUFFER=${BUFFER%/}
+    fi
+    zle ".$WIDGET"
+}
+zle -N accept-line ft_accept_line_cd_up
+
+# 2nd part, completion support...
+function ft_complete_with_dots() {
+    setopt local_options extended_glob
+    local -a cmdline
+    cmdline=( ${(z)BUFFER} )
+    if (( ${#cmdline} == 1 )) && [[ ${cmdline[1]} == ..## ]] ; then
+        BUFFER='cd '
+        for (( i = 2; i <= ${#${cmdline[1]}}; i++ )); do
+            BUFFER="${BUFFER}../"
+        done
+        CURSOR=${#BUFFER}
+    fi
+    zle ".$WIDGET"
+}
+# Disabling for now as I don't know how to fallback to automatic correction...
+#zle -N expand-or-complete ft_complete_with_dots
+
+
+# genpass()
+# Generates a tough password of a given length
+# Borrowed (and slightly modifed) from Seth House github repository.
+
+function genpass() {
+    if [ ! "$1" ]; then
+        echo "Usage: $0 20"
+        echo "For a random, 20-character password."
+        return 1
+    fi
+    dd if=/dev/urandom count=1 2>/dev/null | tr -cd 'A-Za-z0-9' | cut -c-$1
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zshrc.d/50-local.zrc	Sat Jul 14 19:20:57 2012 +0200
@@ -0,0 +1,6 @@
+
+#######################
+# Local customization #
+#######################
+
+[ -f $ZDOTLOCALDIR/zshrc ] && . $ZDOTLOCALDIR/zshrc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zshrc.d/60-vi-showmode.zrc	Sat Jul 14 19:20:57 2012 +0200
@@ -0,0 +1,245 @@
+#
+# Vi Mode
+# This is an old script I have been updating/customizing over
+# the time, I'm unable to mention the original author.
+# Let me know if you know who I should give the credits to.
+#
+# This mode can be enabled/disabled using the variable
+# $SHOWMODE in your $ZDOTLOCALDIR/zshrc.
+#
+# MiKael
+#
+
+if [[ $SHOWMODE != "on" ]]; then
+    # Vi showmode is not enabled--skipping file
+    return 0
+fi
+
+
+#####################
+# Vim-like showmode #
+#####################
+
+# vi keybindings
+bindkey -v
+
+bindkey -M vicmd "^R" redo
+bindkey -M vicmd "u" undo
+bindkey -M vicmd "ga" what-cursor-position
+
+unsetopt promptcr
+setopt transient_rprompt
+
+__string_insert="--INSERT--"
+__string_normal="--NORMAL--"
+__string_replace="--REPLACE-"
+
+redisplay-insert() {
+   show_mode "$__string_insert"
+}
+redisplay-normal() {
+   show_mode "$__string_normal"
+}
+zle -N redisplay-insert
+zle -N redisplay-normal
+bindkey -M viins "^X^R" redisplay-insert
+bindkey -M vicmd "^X^R" redisplay-normal
+
+screenclear () {
+   echo -n "\033[2J\033[400H"
+   builtin zle .redisplay
+   show_mode "$__string_insert"
+}
+zle -N screenclear
+bindkey "" screenclear
+
+function zle-line-finish {
+   export RPS1="$__string_insert"
+}
+zle -N zle-line-finish
+
+show_mode() {
+   export RPS1=$1
+   builtin zle reset-prompt
+   return
+}
+
+
+###       vi-add-eol (unbound) (A) (unbound)
+###              Move  to the end of the line and enter insert mode.
+
+vi-add-eol() {
+   show_mode "$__string_insert"
+   builtin zle .vi-add-eol
+}
+zle -N vi-add-eol
+bindkey -M vicmd "A" vi-add-eol
+
+###       vi-add-next (unbound) (a) (unbound)
+###              Enter insert mode after the  current  cursor  posi­
+###              tion, without changing lines.
+vi-add-next() {
+   show_mode "$__string_insert"
+   builtin zle .vi-add-next
+}
+zle -N vi-add-next
+bindkey -M vicmd "a" vi-add-next
+
+
+###       vi-change (unbound) (c) (unbound)
+###              Read a movement command from the keyboard, and kill
+###              from  the  cursor  position  to the endpoint of the
+###              movement.  Then enter insert mode.  If the  command
+###              is vi-change, change the current line.
+
+vi-change() {
+   show_mode "$__string_insert"
+   builtin zle .vi-change
+}
+zle -N vi-change
+bindkey -M vicmd "c" vi-change
+
+###       vi-change-eol (unbound) (C) (unbound)
+###              Kill  to the end of the line and enter insert mode.
+
+vi-change-eol() {
+   show_mode "$__string_insert"
+   builtin zle .vi-change-eol
+}
+zle -N vi-change-eol
+bindkey -M vicmd "C" vi-change-eol
+
+###       vi-change-whole-line (unbound) (S) (unbound)
+###              Kill the current line and enter insert mode.
+
+vi-change-whole-line() {
+   show_mode "$__string_insert"
+   builtin zle .vi-change-whole-line
+}
+zle -N vi-change-whole-line
+bindkey -M vicmd "S" vi-change-whole-line
+
+###       vi-insert (unbound) (i) (unbound)
+###              Enter insert mode.
+
+vi-insert() {
+   show_mode "$__string_insert"
+   builtin zle .vi-insert
+}
+zle -N vi-insert
+bindkey -M vicmd "i" vi-insert
+
+###       vi-insert-bol (unbound) (I) (unbound)
+###              Move to the first non-blank character on  the  line
+###              and enter insert mode.
+
+vi-insert-bol() {
+   show_mode "$__string_insert"
+   builtin zle .vi-insert-bol
+}
+zle -N vi-insert-bol
+bindkey -M vicmd "I" vi-insert-bol
+
+###       vi-open-line-above (unbound) (O) (unbound)
+###              Open a line above the cursor and enter insert mode.
+
+vi-open-line-above() {
+   show_mode "$__string_insert"
+   builtin zle .vi-open-line-above
+}
+zle -N vi-open-line-above
+bindkey -M vicmd "O" vi-open-line-above
+
+###       vi-open-line-below (unbound) (o) (unbound)
+###              Open a line below the cursor and enter insert mode.
+
+vi-open-line-below() {
+   show_mode "$__string_insert"
+   builtin zle .vi-open-line-below
+}
+zle -N vi-open-line-below
+bindkey -M vicmd "o" vi-open-line-below
+
+###       vi-substitute (unbound) (s) (unbound)
+###              Substitute the next character(s).
+
+vi-substitute() {
+   show_mode "$__string_insert"
+   builtin zle .vi-substitute
+}
+zle -N vi-substitute
+bindkey -M vicmd "s" vi-substitute
+
+
+###       vi-replace (unbound) (R) (unbound)
+###              Enter overwrite mode.
+###
+
+vi-replace() {
+   show_mode "$__string_replace"
+   builtin zle .vi-replace
+}
+zle -N vi-replace
+bindkey -M vicmd "R" vi-replace
+
+###       vi-cmd-mode (^X^V) (unbound) (^[)
+###              Enter  command  mode;  that  is, select the `vicmd'
+###              keymap.  Yes, this is bound  by  default  in  emacs
+###              mode.
+
+vi-cmd-mode() {
+   show_mode "$__string_normal"
+   builtin zle .vi-cmd-mode
+}
+zle -N vi-cmd-mode
+bindkey -M viins "" vi-cmd-mode
+
+
+###       vi-oper-swap-case
+###              Read a movement command from the keyboard, and swap
+###              the case of all characters from the cursor position
+###              to the endpoint of the movement.  If  the  movement
+###              command  is vi-oper-swap-case, swap the case of all
+###              characters on the current line.
+###
+
+bindkey -M vicmd "g~" vi-oper-swap-case
+
+
+bindkey -M vicmd "[2~" vi-insert
+bindkey -M vicmd 'q'     push-line
+bindkey -M vicmd '[5~' history-beginning-search-backward # PgUp
+bindkey -M vicmd '[6~' history-beginning-search-forward  # PgDn
+
+bindkey -M viins '[5~' history-beginning-search-backward # PgUp
+bindkey -M viins '[6~' history-beginning-search-forward  # PgDn
+bindkey -M viins '[7~' beginning-of-line
+bindkey -M viins '[8~' end-of-line
+bindkey -M viins '^A'    beginning-of-line
+bindkey -M viins '^E'    end-of-line
+bindkey -M viins '[3~' delete-char
+bindkey -M viins ''  up-line-or-history
+bindkey -M viins ''  down-line-or-history
+bindkey -M viins '^Xc'   copy-prev-word
+bindkey -M viins '^Xf'   _correct_filename
+bindkey -M viins '^_'    undo
+bindkey -M viins '^K'    vi-change-eol
+bindkey -M viins '^R'    history-incremental-search-backward
+bindkey -M viins '^O'    accept-line-and-down-history
+bindkey -M viins '^T'    transpose-chars
+bindkey -M viins '^Xm'   _most_recent_file
+
+bindkey -M viins -s '^X^H' 'hash -r\n'
+
+
+if [[ -z ${TERM:#screen} ]]; then
+  bindkey -M viins '[1~'  beginning-of-line   # Home
+  bindkey -M viins '[4~'  end-of-line         # End
+fi
+
+# Edit the command line using your usual editor.
+autoload edit-command-line
+zle -N edit-command-line
+bindkey -M vicmd v edit-command-line
+
+export RPS1="$__string_insert"