Skip to content

Instantly share code, notes, and snippets.

@singingwolfboy
Created August 21, 2012 15:39
Show Gist options
  • Save singingwolfboy/3416664 to your computer and use it in GitHub Desktop.
Save singingwolfboy/3416664 to your computer and use it in GitHub Desktop.
autoload -U compinit promptinit colors
compinit
promptinit
colors
autoload -Uz vcs_info
vcs_info
setopt prompt_subst
# vim-style keybindings
bindkey -v
# delete past start char of insert mode
bindkey "^W" backward-kill-word # vi-backward-kill-word
bindkey "^H" backward-delete-char # vi-backward-delete-char
bindkey "^U" kill-line # vi-kill-line
bindkey "^?" backward-delete-char # vi-backward-delete-char
# vcs_info
zstyle ':vcs_info:*' actionformats \
'%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
zstyle ':vcs_info:*' formats \
'%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
zstyle ':vcs_info:*' enable git svn
# autocomplete man pages
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*:manuals.*' insert-sections true
zstyle ':completion:*:man:*' menu yes select
precmd () { vcs_info }
PROMPT="%{$fg[green]%}%n %{$fg[white]%}%~ %{$fg[blue]%}"'${vcs_info_msg_0_}'"%{$reset_color %}
%# "
# http://pthree.org/2009/03/28/add-vim-editing-mode-to-your-zsh-prompt/
# http://zshwiki.org/home/examples/zlewidgets
function zle-line-init zle-keymap-select {
local CMD_TEXT="%{$fg[yellow]%}COMMAND%{$reset_color%}"
local INS_TEXT=""
VIMODE="${${KEYMAP/vicmd/${CMD_TEXT}}/(main|viins)/${INS_TEXT}}"
zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select
RPROMPT='$VIMODE'
# hub
if which hub > /dev/null; then
eval "$(hub alias -s zsh)"
local COMPL=/opt/local/share/zsh/site-functions/hub.zsh_completion
test -r $COMPL && source $COMPL
gitcmd="hub"
else
gitcmd="git"
fi
# git wrapper
git() {
command $gitcmd "$@";
if [[ $? == 0 && $1 == 'clone' ]]; then
# install git hooks
local DIR=`ls -d *(/om[1])` # last modified directory
if [[ -d $DIR/hooks ]]; then
for hook in `ls $DIR/hooks`; do
ln -s ../../hooks/$hook $DIR/.git/hooks/$hook
done
echo "Git hooks installed."
fi
fi
}
if [ -s /opt/local/share/scm_breeze/scm_breeze.sh ]; then
source /opt/local/share/scm_breeze/scm_breeze.sh;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment