Skip to content

Instantly share code, notes, and snippets.

@t-mart
Created January 26, 2012 06:57
Show Gist options
  • Save t-mart/1681445 to your computer and use it in GitHub Desktop.
Save t-mart/1681445 to your computer and use it in GitHub Desktop.
bad hook
#!/usr/bin/zsh
typeset -U fpath #make fpath unique
typeset -U path #make path unique
autoload -U colors && colors
autoload -Uz vcs_info
autoload -U tetris
autoload -U compinit
export EDITOR='vim' #set editor var, as well as zsh vi mode
#
#color the results of ls
#see http://www.bigsoft.co.uk/blog/index.php/2008/04/11/configuring-ls_colors
export LS_COLORS="rs=0:di=04;34:ln=target:mh=00:pi=40;33:so=35:do=35:bd=40;33:cd=40;91:or=40;31:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=04;32:\
*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.tlz=00;31:*.txz=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.dz=00;31:*.gz=00;31:*.lz=00;31:*.xz=00;31:*.bz2=00;31:*.bz=00;31:*.tbz=00;31:*.tbz2=00;31:*.tz=00;31:*.deb=00;31:*.rpm=00;31:*.jar=00;31:*.rar=00;31:*.ace=00;31:*.zoo=00;31:*.cpio=00;31:*.7z=00;31:*.rz=00;31:\
*.jpg=00;35:*.jpeg=00;35:*.gif=00;35:*.bmp=00;35:*.pbm=00;35:*.pgm=00;35:*.ppm=00;35:*.tga=00;35:*.xbm=00;35:*.xpm=00;35:*.tif=00;35:*.tiff=00;35:*.png=00;35:*.svg=00;35:*.svgz=00;35:*.mng=00;35:*.pcx=00;35:\
*.mov=00;35:*.mpg=00;35:*.mpeg=00;35:*.m2v=00;35:*.mkv=00;35:*.ogm=00;35:*.mp4=00;35:*.m4v=00;35:*.mp4v=00;35:*.vob=00;35:*.qt=00;35:*.nuv=00;35:*.wmv=00;35:*.asf=00;35:*.rm=00;35:*.rmvb=00;35:*.flc=00;35:*.avi=00;35:*.fli=00;35:*.flv=00;35:*.gl=00;35:*.dl=00;35:*.xcf=00;35:*.xwd=00;35:*.yuv=00;35:*.cgm=00;35:*.emf=00;35:*.axv=00;35:*.anx=00;35:*.ogv=00;35:*.ogx=00;35:\
*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:\
*.rb=32:*.c=32:*.py=32"
HISTFILE=~/.zsh_history # file for reading and writing history
HISTFILESIZE=65536 # the max size of that file
HISTSIZE=4096 # number of history lines kept in process
SAVEHIST=4096 # max number of lines saved
REPORTTIME=30 # give me time stats on commands that take >= x seconds
WATCH=notme # watch other users logging in or out
WATCHFMT='%n %a %l from %m at %T.' # report it in this format
LOGCHECK=60 # and give me reports every x seconds
setopt SHARE_HISTORY # allow all concurrent shells to show up in history, but with BANG_HIST, `history` command must be executed
setopt APPEND_HISTORY # don't overwrite old history files, just append
setopt INC_APPEND_HISTORY # append at execution, not at shell exit
setopt HIST_VERIFY # ask me to verify my !-history substitutions (so I don't inadvertently write the wrong thing)
setopt HIST_IGNORE_DUPS # don't save adjacent duplicate lines
setopt HIST_EXPIRE_DUPS_FIRST # if this history is filled up to HISTSIZE, delete old dups
setopt NO_HUP # keep bg tasks running even if originating shell is closed
setopt LOCAL_OPTIONS # options set in functions have no effect outside
setopt LOCAL_TRAPS # same, but for traps
setopt AUTO_NAME_DIRS # process named dirs, otherwise i think they wont get recognized
setopt AUTO_CD # allow ommission of `cd` to switch dirs. ex. `bin` (no command) changes you to bin/
setopt CD_ABLE_VARS # if a path contains a part that doesn't exist, try and see it thats a variable and evaluate that
setopt EXTENDED_GLOB # add more pattern features
setopt CORRECT # try to correct misspelled commands
setopt PROMPT_SUBST # expand the prompt each time it's drawn
#vcs_info
zstyle ':vcs_info:*' enable git cvs svn
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr '%F{2}*%f'
zstyle ':vcs_info:*' unstagedstr '%F{1}*%f'
zstyle ':vcs_info:*' actionformats \
'%F{6}[%b%f%c%u%m%F{6}|%a]%f'
zstyle ':vcs_info:*' formats \
'%F{6}[%b%f%c%u%m%F{6}]%f'
# don't need this if i only use git...knock on wood
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-stash #hooks attached here
####this doesn't work ####
#error is "+vi-git-untracked:1: no matches found: [0]"
function +vi-git-untracked() {
if [[ -n ${$(git ls-files --exclude-standard --others | head -n 1)} ]] ; then [0]
hook_com[misc]+="%{$fg[yellow]%}*%{$reset_color%}"
fi
}
####this does work####
# Show count of stashed changes
# thanks https://github.com/whiteinge/dotfiles/blob/master/.zsh_shouse_prompt
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)
#~ is for stash...get it? ~ is a little moustache
hook_com[misc]+=" %{$fg[yellow]%}(~${stashes})%{$reset_color%}"
fi
}
vcs_info_wrapper() {
vcs_info
if [ -n "$vcs_info_msg_0_" ]; then
echo "${vcs_info_msg_0_} "
fi
}
PROMPT='%{$reset_color%}%B%n%b@%{$fg[yellow]%}%m%{$reset_color%} %{$fg[blue]%}%~%{$reset_color%} %{$fg[cyan]%}$(vcs_info_wrapper)%{$reset_color%}%{$fg[green]%}%#%{$reset_color%} '
RPROMPT='[%{$fg[magenta]%}%?%{$reset_color%}]'
#tetris
zle -N tetris
bindkey  tetris
function mkcd() { mkdir "$@"; cd "$@" }
#rbenv
if [[ -d $HOME/.rbenv/bin ]]; then
path=($HOME/.rbenv/bin $path)
eval "$(rbenv init -)"
fi
#latex
if [[ -d /usr/local/texlive/2011/bin/i386-linux ]]; then
path=(/usr/local/texlive/2011/bin/i386-linux $path)
fi
# completion
compinit -C
zstyle ':completion:*' list-colors "$LS_COLORS" # complete with LS_COLORS
zstyle ':completion:*' use-cache 1 # cache completions
zstyle ':completion:*' cache-path ~/.zsh/cache # use this cache file
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment