Skip to content

Instantly share code, notes, and snippets.

@fallwith
Created June 22, 2011 18:01
Show Gist options
  • Save fallwith/1040696 to your computer and use it in GitHub Desktop.
Save fallwith/1040696 to your computer and use it in GitHub Desktop.
ZSH config (~/.zshrc)
# Use the remainder of this file only with interactive shells
[ -z "$PS1" ] && return
# Enable prompt substitution and colors
setopt prompt_subst
autoload colors
colors
# Set the prompts
ruby_version() {
echo " $(echo $MY_RUBY_HOME | sed -e 's_^.*/__' | sed -e 's/-p[0-9][0-9]*//')"
}
local rubyv='%{$fg[cyan]%}$(ruby_version)%{$reset_color%}'
local gemv='%{$fg[cyan]%}gems-$(gem -v)%{$reset_color%}'
local pwd='%{$fg[magenta]%}%~%{$reset_color%}'
local return_code='%(?..%{$fg[red]%}%? ↵%{$reset_color%})'
local git_branch='%{$fg[yellow]%}$([ -e .git ] && git bname)%{$reset_color%}'
PROMPT="${pwd} $> "
RPROMPT="${return_code} ${rubyv}/${gemv} ${git_branch}"
export EDITOR='mate -w'
export PATH=~/bin:/usr/local/bin:/usr/local/sbin:$PATH
#export TERM=xterm-256color
# history
export HISTFILE=~/.zsh-history.$ZSH_VERSION
export HISTSIZE=500
export SAVEHIST=50000
export HISTIGNORE="&:[bf]g:exit:history:top:clear:cd:cd ..:cd.."
setopt INC_APPEND_HISTORY HIST_IGNORE_ALL_DUPS HIST_REDUCE_BLANKS HIST_SAVE_NO_DUPS HIST_IGNORE_SPACE NO_BANG_HIST
# zsh completion / misc opts
autoload -U compinit
compinit -i
zstyle ':completion:*' hosts off # don't autocomplete host names
unsetopt menu_complete # don't insert the first match upon ambiguous completion
zstyle ':completion:*:*:*:*:*' menu select # use an interactive menu (moveable highlight bar)
unsetopt flowcontrol # disable flow control (starting/starting flow to the terminal)
setopt complete_in_word
setopt always_to_end
# report execution time for anything taking longer than n secs
export REPORTTIME=25
# do not overwrite files with > (use >! instead)
setopt NOCLOBBER
# -l = long format
# -A = include hidden (.*) files except '.' and '..'
# -p = mark directories with a trailing slash ('/')
alias ll='ls -lAp'
# use otool as an ldd-alike on OS X
[[ ($(uname) == 'Darwin') ]] && alias ldd='otool -L'
# (OS X) clear Flash cache. Safari, Firefox, and Chrome all write to here
# but never clear it (even through their clearing tasks). Alternatively, use the
# Settings Manager in a browser to clear specific content item by item:
# http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager07.html
alias clearflash='rm -rf ~/Library/Preferences/Macromedia/Flash\ Player/#SharedObjects/* ~/Library/Preferences/Macromedia/Flash\ Player/macromedia.com/support/flashplayer/sys/*'
# Remove all .DS_Store files from pwd or beneath the optional path specified
dsclean() {
if [ $# -eq 0 ]; then BASEDIR=.; else BASEDIR=$1; fi
find $BASEDIR -name .DS_Store -exec rm -v '{}' +
}
# Clean up source code by converting tabs to 2 spaces, Windows newlines to
# unix ones, and by stripping away trailing whitespace. Pass in a list of
# files to clean, or let ack find a list of suitable candidates.
clean() {
if [ $1 ]; then
files=$@
else
files=`ack " +$|\t|\r" -l`
fi
echo $files|xargs perl -pi -e "s/\r\n?/\n/g;s/\t/ /g;s/[ ]*$//g"
}
# Redis builds
if [ -d ~/Workspace/redis_builds ]; then
export PATH=~/Workspace/redis_builds/latest/darwin/bin:$PATH
fi
# EC2
if [ -d $HOME/.ec2 ]; then
ec2_tool_dir=/usr/local/Cellar/ec2-api-tools
ec2_api_ver=$(/bin/ls $ec2_tool_dir | tail -1)
export EC2_HOME="$ec2_tool_dir/$ec2_api_ver/jars"
export PATH=$EC2_HOME/bin:$PATH
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
export EC2_PRIVATE_KEY="$(/bin/ls $HOME/.ec2/pk-*.pem)"
export EC2_CERT="$(/bin/ls $HOME/.ec2/cert-*.pem)"
alias ess="ssh -i $HOME/.ec2/id_rsa-playco-keypair -o StrictHostKeyChecking=no -l root"
alias pss="ssh -i $HOME/.ec2/id_rsa-playco-user -o StrictHostKeyChecking=no -l playco"
fi
# RVM
unsetopt auto_name_dirs # fix for '~rvm_rvmrc_cwd' dir name display
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
alias rvmdefaults="rvm use ruby-1.9.2-p180@fallwith --create --install --default && if [ $(gem -v) != '1.8.5' ]; then rvm rubygems 1.8.5; fi"
# Replacement for Homebrew 'brew update'
alias brewupdate="opwd=`pwd` && cd `brew --prefix` && git init && git fetch https://github.com/mxcl/homebrew.git && git reset --hard FETCH_HEAD && cd $opwd"
# Fix OS X Homebrew permissions (when /usr/local can't be written to)
alias brewfix="sudo dscl /Local/Default -append /Groups/staff GroupMembership $USER"
# mysql
alias mysqlstart="launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist"
alias mysqlstop="launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist"
# disable zsh globbing functionality when using rake (otherwise passing commands to
# rake tasks will collide)
alias rake='noglob rake'
# iTerm2
alias itermsaveconfig="cp $HOME/Library/Preferences/com.googlecode.iterm2.plist $HOME/Dropbox/Development/Dotfiles/"
alias itermloadconfig="rm $HOME/Library/Preferences/com.googlecode.iterm2.plist && cp $HOME/Dropbox/Development/Dotfiles/com.googlecode.iterm2.plist $HOME/Library/Preferences/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment