Skip to content

Instantly share code, notes, and snippets.

@jtimberman
Created October 22, 2009 05:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jtimberman/215751 to your computer and use it in GitHub Desktop.
Save jtimberman/215751 to your computer and use it in GitHub Desktop.
# Joshua Timberman <joshua@housepub.org>
# My .zshrc, modified from:
#
# $Id: .zshrc,v 1.1 2006/04/19 22:08:04 adam Exp $
#
# Adam's zshrc - <adam@stalecoffee.org>
#
# Stolen entirely from --
#
# Andy's zshrc <william.a@carrel.org>
#
#################################################
zshrc_load_status () {
# \e[0K is clear to right
if [[ -n "$ZSH_LOAD_STATUS_DEBUG" ]]; then
echo ".zshrc load: $* ... \e[0K"
else
echo -n "\r.zshrc load: $* ... \e[0K"
fi
}
#################################################
zshrc_load_status 'setting zsh options'
autoload zrecompile
# Changing Directories
setopt auto_cd
setopt auto_pushd
setopt cdable_vars
setopt pushd_ignore_dups
setopt pushd_to_home
# Completion
setopt complete_aliases
setopt complete_in_word
setopt glob_complete
setopt NO_list_ambiguous
setopt NO_list_beep
# Expansion and Globbing
setopt bad_pattern
setopt NO_bare_glob_qual
setopt brace_ccl
setopt NO_case_glob
setopt equals
setopt extended_glob
setopt NO_glob_assign
setopt glob_dots
setopt glob_subst
setopt hist_subst_pattern
setopt NO_nomatch
setopt numeric_glob_sort
setopt rc_expand_param
setopt sh_glob
setopt unset
# History
setopt bang_hist
setopt extended_history
setopt hist_allow_clobber
setopt NO_hist_beep
setopt hist_expire_dups_first
setopt hist_find_no_dups
setopt hist_ignore_all_dups
setopt hist_ignore_dups
setopt hist_ignore_space
setopt hist_no_store
setopt hist_reduce_blanks
setopt hist_save_no_dups
setopt hist_verify
setopt inc_append_history
# Initialisation
setopt all_export
setopt global_export
# Input/Output
setopt correct_all
setopt interactive_comments
setopt path_dirs
setopt NO_rm_star_silent
setopt NO_rm_star_wait
setopt short_loops
# Job Control
setopt check_jobs
setopt NO_hup
setopt long_list_jobs
setopt monitor
setopt notify
# Prompting
setopt NO_prompt_bang
setopt prompt_subst
# Scripts and Functions
setopt eval_lineno
setopt function_argzero
setopt multios
# Shell Emulation
setopt NO_bsd_echo
setopt csh_junkie_history
setopt NO_csh_junkie_loops
setopt NO_csh_junkie_quotes
setopt NO_csh_null_glob
setopt NO_ksh_arrays
setopt NO_ksh_autoload
setopt NO_ksh_option_print
setopt NO_ksh_typeset
setopt posix_builtins
setopt posix_identifiers
setopt NO_sh_file_expansion
setopt NO_sh_nullcmd
setopt NO_sh_option_letters
setopt NO_sh_word_split
# Zle
setopt zle
#################################################
zshrc_load_status 'setting terminal'
bindkey -v
# Make sure that ^Q and ^S do the right thing
stty stop undef
stty start undef
# Fix menu titles and mac backspace keys where needed
case $TERM in
xterm)
precmd () {print -Pn "\e]0;%m: %~\a"}
preexec () {print -Pn "\e]0;%m: %~ - $2\a"}
;;
xterm-color)
precmd () {print -Pn "\e]0;%m: %~\a"}
preexec () {print -Pn "\e]0;%m: %~ - $2\a"}
bindkey '^[[3~' delete-char
bindkey '^?' backward-delete-char
export CLICOLOR=xterm-color
;;
esac
#################################################
zshrc_load_status 'building files'
if [ \! -f ~/.cvsrc ]; then
echo diff -u > ~/.cvsrc
echo update -dP >> ~/.cvsrc
fi
if [ \! -x ~/.lesspipe.sh ]; then
cat <<EOLESSPIPE > ~/.lesspipe.sh
#!/bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gzip -d -c $1 2>/dev/null
;;
*.bz2) bzip2 -d -c $1 2>/dev/null
;;
esac
EOLESSPIPE
chmod +x ~/.lesspipe.sh
fi
#################################################
zshrc_load_status 'setting environment'
if [ -e /usr/share/locale/en_US.UTF-8 ]; then
LANG=en_US.UTF-8
fi
PROMPT="\`if [[ \$? = "0" ]]; then echo '\e[32m%m\e[0m'; else echo '\e[31m%m\e[0m' ; fi\`:%~
%# "
PROMPT2=" "
CVS_RSH=ssh
RSYNC_RSH=ssh
# Let's find a nice pretty editor to play with
if whence -cp vim > /dev/null; then
EDITOR=`whence -cp vim`
elif whence -cp vi > /dev/null; then
EDITOR=`whence -cp vi`
fi
if [ 'Darwin' == `uname` ]
then
macpaths="/usr/local/homebrew/bin:/usr/local/homebrew/sbin:"
macman="/usr/local/homebrew/share/man:"
fi
PATH="$macpaths/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:$HOME/bin"
MANPATH="$macman/usr/man:/usr/local/man:/usr/share/man:/usr/local/share/man:/usr/X11R6/man"
if whence -cp less > /dev/null; then
PAGER=`whence -cp less`
alias more="/usr/bin/less"
if [ -x $HOME/.lesspipe.sh ]; then
LESSOPEN=\|$HOME/.lesspipe.sh\ %s
fi
fi
if [ -d /System/Library/Frameworks/JavaVM.framework/Home ]
then
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
fi
LOGCHECK=60
WATCHFMT="[%B%t%b] %B%n%b has %a %B%l%b from %B%M%b"
umask 022
#################################################
zshrc_load_status 'prompt system'
autoload -U promptinit
promptinit
HISTFILE=~/.zsh_history
HISTSIZE=9999
SAVEHIST=9999
#################################################
zshrc_load_status 'completion system'
autoload -U compinit
compinit
# General completion technique
#zstyle ':completion:*' completer _complete _correct _approximate _prefix
zstyle ':completion:*' completer _complete _prefix
zstyle ':completion::prefix-1:*' completer _complete
zstyle ':completion:incremental:*' completer _complete _correct
zstyle ':completion:predict:*' completer _complete
# Completion caching
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion::complete:*' cache-path ~/.zsh-compcache-$HOST
if [ \! -d ~/.zsh-compcache-$HOST ]
then
mkdir ~/.zsh-compcache-$HOST
fi
# Expand partial paths
zstyle ':completion:*' expand 'yes'
zstyle ':completion:*' squeeze-slashes 'yes'
# Provide away to expand out all matches
zstyle ':completion:all-matches::::' completer _all_matches _complete
zstyle ':completion:all-matches:*' old-matches true
zstyle ':completion:all-matches:*' insert true
zle -C all-matches complete-word _generic
bindkey '^Xx' all-matches
# Include non-hidden directories in globbed file completions
# for certain commands
#zstyle ':completion::complete:*' \
# tag-order 'globbed-files directories' all-files
#zstyle ':completion::complete:*:tar:directories' file-patterns '*~.*(-/)'
# Don't complete backup files as executables
zstyle ':completion:*:complete:-command-::commands' ignored-patterns '*\~'
# Don't complete "CVS" directories
#zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)CVS'
#zstyle ':completion:*:cd:*' ignored-patterns '(*/)#CVS'
# Ignore completion functions for commands you don't have:
zstyle ':completion:*:functions' ignored-patterns '_*'
# Separate matches into groups
zstyle ':completion:*:matches' group 'yes'
zstyle ':completion:*' group-name ''
# Describe each match group.
zstyle ':completion:*:descriptions' format "%B---- %d%b"
# Messages/warnings format
zstyle ':completion:*:messages' format '%B%U---- %d%u%b'
zstyle ':completion:*:warnings' format '%B%U---- no match for: %d%u%b'
# Describe options in full
zstyle ':completion:*:options' description 'yes'
zstyle ':completion:*:options' auto-description '%d'
users=( $USERNAME root )
zstyle ':completion:*' users $users
# Zsh doesn't complete for locales correctly on BSD-derivatives yet...
if [[ $OSTYPE = darwin* || $OSTYPE = *bsd* ]]; then
bsd_locale_func() {
local locales
locales=( /usr/share/locale/*(/:t) )
_wanted locales expl locale compadd "$@" -a locales
}
compdef 'bsd_locale_func' -value-,LANG,-default- -value-,LANGUAGE,-default- -P -value-,LC_\*,-default-
# zstyle ':completion:*' locales $locales
fi
if [[ $ZSH_VERSION > 3.1.5 ]]; then
zmodload -i zsh/complist
zstyle ':completion:*' list-colors ''
zstyle ':completion:*:*:kill:*:processes' list-colors \
'=(#b) #([0-9]#)*=0=01;31'
# completion colours
zstyle ':completion:*' list-colors "$LS_COLORS"
fi
#################################################
zshrc_load_status 'setup aliases'
if [ 'Darwin' == `uname` ]
then
alias ls="ls -FG"
alias vi='/usr/bin/vim'
alias vim='/usr/bin/vim'
else
alias ls="ls --color=auto -hF --file-type"
fi
alias history="fc -liD 1"
alias du="du -mcx"
alias free="free -m"
alias today="date +%F"
alias ps="COLUMNS=320 ps"
alias -- -="cd -"
alias jpp='ruby -e "%w(open-uri rubygems json).each{|l|require l};puts JSON.pretty_generate(JSON.parse(open(ARGV[0]).read))"'
alias gitp="git log -p"
alias gitf="git log --pretty=format:'%Cgreen%ad %cn %Cblue%h %Creset%s' --date=short"
echo -n "\r\e[0K"
uname -sr
setopt NO_all_export
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment