Created
September 9, 2008 19:17
-
-
Save chrismcg/9739 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export LSCOLORS=gxfxcxdxbxegedabagacad | |
if [[ $OS == 'Linux' ]]; then | |
alias ls='ls --color=auto' | |
else | |
alias ls='ls -G' | |
fi | |
alias ll='ls -l' | |
alias lls='ll -S' | |
alias lt='ll -t' | |
alias ltr='ls -ltr' | |
alias llsh='ll -Sh' | |
alias la='ls -a' | |
alias ...='../..' | |
alias ....='../../..' | |
alias .....='../../../..' | |
alias mkdir='nocorrect mkdir' | |
alias mv='nocorrect mv' | |
alias wn="svn st | grep '?'" | |
alias grep="grep --colour=auto" | |
alias updots="cd ~/._dotfiles && git pull && cd -" | |
# rails aliases | |
alias rt="rake" | |
alias rtu="rake test:units" | |
alias rtf="rake test:functionals" | |
alias rti="rake test:integration" | |
alias mig="rake migrate" | |
alias ss='script/server' | |
alias sc='script/console' | |
alias mr="mongrel_rails start" | |
alias mrp="mongrel_rails start -e production" | |
alias mcu="mongrel_rails cluster::start" | |
alias mcd="mongrel_rails cluster::stop" | |
# git aliases | |
alias b='git checkout' | |
alias c='git commit -a -v' | |
alias s='git status' | |
alias d='git diff' | |
alias ds='git staged' | |
alias gitco='git checkout' | |
alias gita='git add' | |
alias gitci='git commit' | |
alias gits='git status' | |
alias gitb='git branch' | |
dotf=~/._dotfiles | |
# OSX Specific Stuff | |
if [[ $OS == 'Darwin' ]]; then | |
alias pi="sudo port install" | |
alias pd="port deps" | |
alias pv="port variants" | |
fi | |
if [[ $SETUP_DELETE_KEYS == 'yes' ]]; then | |
bindkey "^[[3~" delete-char | |
bindkey "^?" backward-delete-char | |
fi | |
# Main machine aliases | |
if [[ $MACHINE == 'shiny' || $MACHINE == 'cooper' ]]; then | |
alias m='mate app components config db lib public script test vendor/plugins' | |
alias less='less -r' | |
alias svndiff="svn diff --diff-cmd=fmdiff" | |
sysgems=/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/lib/ruby/gems/1.8/gems | |
gems=/Library/Ruby/Gems/1.8/gems | |
fi | |
# The following lines were added by compinstall | |
zstyle ':completion:*' completer _expand _complete _correct _approximate | |
zstyle ':completion:*' group-name '' | |
zstyle ':completion:*' insert-unambiguous false | |
zstyle ':completion:*' list-colors '' | |
zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the character to insert%s' | |
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'r:|[._-]=** r:|=**' 'l:|=* r:|=*' | |
zstyle ':completion:*' max-errors 2 | |
zstyle ':completion:*' menu select=long | |
zstyle ':completion:*' original false | |
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s' | |
zstyle :compinstall filename '~/.zsh/completion' | |
autoload -Uz compinit | |
compinit | |
# End of lines added by compinstall | |
if [[ $MACHINE == 'shiny' ]]; then | |
PATH="$HOME/bin:$HOME/bin/local:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:$PATH" | |
MANPATH="/opt/local/man:~/share/man:$MANPATH" | |
export LC_CTYPE=en_GB.UTF-8 | |
export EDITOR='mate -w' | |
export LESSEDIT='mate -l %lm %f' | |
export EVENT_NOKQUEUE=1 | |
fi | |
function mkcd() { | |
mkdir -p $1 && cd $1 | |
} | |
function gitqc() { | |
git commit -a -m $1 && git svn dcommit | |
} | |
function changes_since_last_deploy() { | |
last_date=$(ssh kd01 ls -ltr www/current | cut -d'/' -f 6) | |
git_date=$(ruby -rdate -e "puts DateTime.parse('$last_date')") | |
git log --pretty=oneline --since=$git_date | cut -d" " -f 2- | |
} | |
function add_local_domain() { | |
sudo /usr/bin/dscl localhost -create /Local/Default/Hosts/$1 IPAddress 127.0.0.1 | |
} | |
function java_ruby() { | |
export PATH=~/dev/java/jruby/bin:$PATH | |
export CUSTOM_RUBY=java | |
} | |
HISTSIZE=1000 | |
SAVEHIST=1000 | |
setopt APPEND_HISTORY EXTENDED_HISTORY INC_APPEND_HISTORY HIST_IGNORE_DUPS | |
HISTFILE=~/.history | |
setopt AUTO_CD MULTIOS CORRECT_ALL AUTO_NAME_DIRS | |
setopt auto_pushd | |
setopt pushd_ignore_dups | |
DIRSTACKSIZE=20 | |
bindkey -e | |
# nice prompt | |
# from http://www.aperiodic.net/phil/prompt/ | |
function precmd { | |
local TERMWIDTH | |
(( TERMWIDTH = ${COLUMNS} - 1 )) | |
### current git branch | |
### modified from http://madism.org/~madcoder/dotfiles/zsh/60_prompt | |
if which git > /dev/null; then | |
if [[ $(git-rev-parse --git-dir 2> /dev/null) != '' ]]; then | |
PR_GIT=" (${$(git-symbolic-ref HEAD 2> /dev/null):t})" | |
else | |
PR_GIT='' | |
fi | |
fi | |
if [[ $CUSTOM_RUBY != '' ]]; then | |
PR_RUBY=" ($CUSTOM_RUBY ruby) " | |
else | |
PR_RUBY='' | |
fi | |
### | |
# Truncate the path if it's too long. | |
PR_FILLBAR="" | |
PR_PWDLEN="" | |
local promptsize=${#${:-( %H:%M) }} | |
local pwdsize=${#${(%):-%~}} | |
local gitsize=${#${PR_GIT}} | |
local rubysize=${#${PR_RUBY}} | |
if [[ "$promptsize + $pwdsize + $gitsize + $rubysize" -gt $TERMWIDTH ]]; then | |
((PR_PWDLEN=$TERMWIDTH - $promptsize)) | |
else | |
PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize + $gitsize + $rubysize)))..${PR_HBAR}.)}" | |
fi | |
PR_APM_RESULT= | |
} | |
setopt extended_glob | |
preexec () { | |
if [[ "$TERM" == "screen" ]]; then | |
local CMD=${1[(wr)^(*=*|sudo|-*)]} | |
echo -n "\ek$CMD\e\\" | |
fi | |
} | |
setprompt () { | |
### | |
# Need this so the prompt will work. | |
setopt prompt_subst | |
### | |
# See if we can use colors. | |
autoload colors zsh/terminfo | |
if [[ "$terminfo[colors]" -ge 8 ]]; then | |
colors | |
fi | |
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do | |
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}' | |
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}' | |
(( count = $count + 1 )) | |
done | |
PR_NO_COLOUR="%{$terminfo[sgr0]%}" | |
### | |
# See if we can use extended characters to look nicer. | |
typeset -A altchar | |
set -A altchar ${(s..)terminfo[acsc]} | |
PR_SET_CHARSET="%{$terminfo[enacs]%}" | |
PR_SHIFT_IN="%{$terminfo[smacs]%}" | |
PR_SHIFT_OUT="%{$terminfo[rmacs]%}" | |
PR_HBAR=${altchar[q]:--} | |
PR_ULCORNER=${altchar[l]:--} | |
PR_LLCORNER=${altchar[m]:--} | |
PR_LRCORNER=${altchar[j]:--} | |
PR_URCORNER=${altchar[k]:--} | |
### | |
# Decide if we need to set titlebar text. | |
case $TERM in | |
xterm*) | |
PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~\a%}' | |
;; | |
screen) | |
PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | %y\e\\%}' | |
;; | |
*) | |
PR_TITLEBAR='' | |
;; | |
esac | |
### | |
# Decide whether to set a screen title | |
if [[ "$TERM" == "screen" ]]; then | |
PR_STITLE=$'%{\ekzsh\e\\%}' | |
else | |
PR_STITLE='' | |
fi | |
### | |
# APM detection | |
if which ibam > /dev/null; then | |
PR_APM='$PR_RED${${PR_APM_RESULT[(f)1]}[(w)-2]}%%(${${PR_APM_RESULT[(f)3]}[(w)-1]})$PR_LIGHT_BLUE:' | |
elif which apm > /dev/null; then | |
PR_APM='$PR_RED${PR_APM_RESULT[(w)5,(w)6]/\% /%%}$PR_LIGHT_BLUE:' | |
else | |
PR_APM='' | |
fi | |
### | |
# Finally, the prompt. | |
PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\ | |
$PR_BLUE%D{%H:%M} \ | |
$PR_CYAN%$PR_PWDLEN<...<%~%<<\ | |
$PR_BLUE$PR_GIT $PR_RUBY$PR_BLUE$PR_SHIFT_IN$PR_HBAR$PR_HBAR${(e)PR_FILLBAR}$PR_HBAR$PR_CYAN$PR_SHIFT_OUT\ | |
$PR_GREEN%(!.%SROOT%s.%n)@%m %(?..$PR_LIGHT_RED%? $PR_BLUE)\ | |
${(e)PR_APM}$PR_YELLOW\ | |
%(!.$PR_RED.$PR_WHITE)$PR_BLUE%#$PR_BLUE$PR_SHIFT_OUT\ | |
$PR_NO_COLOUR ' | |
# RPROMPT=' $PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_BLUE$PR_HBAR$PR_SHIFT_OUT\ | |
# ($PR_YELLOW%D{%a,%b%d}$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_LRCORNER$PR_SHIFT_OUT$PR_NO_COLOUR' | |
PS2='$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\ | |
$PR_BLUE$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT(\ | |
$PR_LIGHT_GREEN%_$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\ | |
$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR ' | |
} | |
setprompt | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment