# anyall.org/.zshrc - for zsh, the best shell in the world # brendan oconnor - brenocon at gmail - anyall.org # if [[ -f ~/.profile ]] && [ ! "$PROFILE_READ" ]; then # export PROFILE_READ=yes # source ~/.profile # fi #[[ -f ~/.inputrc ]] && export INPUTRC=~/.inputrc [[ -f ~/db.sh ]] && source ~/db.sh uname=`uname` [[ $uname == Darwin ]] && is_mac=yes [[ $uname == Darwin ]] && is_local=yes [[ "$is_local" = yes ]] && export DISPLAY=${DISPLAY:-:0.0} if [ "$is_local" ] && [ "$is_mac" ]; then alias cm="/Applications/Emacs.app/Contents/MacOS/Emacs" alias ccm=/Applications/Emacs.app/Contents/MacOS/bin/emacs # mac gui apps # function better than alias: no hanging for tab completion excel() { open -a "/Applications/Microsoft Office 2008/Microsoft Excel.app" "$@" } word() { open -a "/Applications/Microsoft Office 2008/Microsoft Word.app" "$@" } ppt() { open -a "Microsoft Powerpoint" "$@" } ff() { open -a "/Applications/Firefox.app" "$@" } safari() { open -a Safari "$@" } chrome() { open -a /Applications/Google\ Chrome.app "$@" } smul() { open -a Smultrion "$@" } texshop(){ open -a TexShop "$@" } alias apps='open /Applications' fi #alias lp='ls --color ^*(~|.pyc|ptlc)(^/)' function abspath { if [ -d "$1" ]; then (cd "$1" && pwd) else echo "$(abspath $(dirname $1))/$(basename $1)" fi } function habspath { echo "$(hostname -s):$(abspath $1)" } function lsfull { ls -d $(abspath $1) # if [[ "$1" == /* ]]; then # else # ls -d $(pwd)/$1 # fi } function 'h?' { history +1 | perl -pe "s/ *\d+//" | grep "$@" | uniq | grep --color=always "$@" } # alias view='gvim --cmd "au GUIEnter * simalt ~x"' alias v=vim alias vp='vim -S =(echo "se paste\nstart")' #iterm TERM=ansi screws up emacs #alias emacs="TERM=xterm emacs" # alias e="emacs -nw" alias screen='TERM=screen screen' # http://ubuntuforums.org/showthread.php?t=90910 export PYTHONSTARTUP=~/.pythonrc # no spelling corrections (man zshbuiltins) alias mv='nocorrect mv' alias cp='nocorrect cp' alias mkdir='nocorrect mkdir' alias rm='nocorrect rm' alias pu=pushd alias p=popd alias .='pwd' alias ..="cd .." alias ...='cd ../..' alias ....='cd ../../..' alias -- -='cd -' cd () { if [[ "x$*" == "x..." ]]; then cd ../.. elif [[ "x$*" == "x...." ]]; then cd ../../.. elif [[ "x$*" == "x....." ]]; then cd ../../.. elif [[ "x$*" == "x......" ]]; then cd ../../../.. else builtin cd "$@" fi } if ls --color &>/dev/null; then ls_opt="--color=tty" # gnu (linux) else ls_opt="-G" # mac #ls_opt="-F" # less buggy fi alias ls="ls $ls_opt" alias ll='ls -l' export GREP_OPTIONS='--color=auto' alias cgrep='grep --color=always' function lcgrep { grep --color=always "$@" | less -r } alias pyclean='rm -f **/*(.pyc|.ptlc|~)' alias rmtil='rm -f *~ *.pyc' alias rrmtil='rm -f **/*~' # override TERM=screen. need env bcs some apps dont smartly interpret PAGER export PAGER='env TERM=xterm less' export MANPAGER='env TERM=xterm less -Ri' export GIT_PAGER='env TERM=xterm less -RFi' export ACK_PAGER='env TERM=xterm less -RFi' #export LESS='-XRF' #export LESS='-RF' export LESS='-RFi' # export LESS='-i' # git diff unhappy export EDITOR=vim # export SVN_SSH="ssh -l $USER" alias 1='cd -' alias 2='cd +2' alias 3='cd +3' alias 4='cd +4' alias 5='cd +5' alias 6='cd +6' alias 7='cd +7' alias 8='cd +8' alias 9='cd +9' alias d='dirs -v' setopt prompt_subst autoload colors zsh/terminfo autoload -Uz colors colors # if [[ "$terminfo[colors]" -ge 8 ]]; then # colors # fi for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do if [[ "$TERM" == dumb ]]; then eval PR_$color= eval PR_LIGHT_$color= BOLD= UNBOLD= else eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}' eval PR_LIGHT_$color='%{$fg[${(L)color}]%}' BOLD='%B' UNBOLD='%b' fi done PR_NO_COLOUR="%{$terminfo[sgr0]%}" [[ "$TERM" == dumb ]] && PR_NO_COLOUR= ## PS1 and PS2 also work, but conflict with sh/bash. ## PROMPT conflicts with cmd.exe, less important # %m is machine name if [[ "$is_local" == yes ]]; then PROMPT='$BOLD$PR_BLUE%~$UNBOLD $PR_LIGHT_BLUE$PR_GREEN%#$PR_NO_COLOUR ' # PROMPT='$BOLD$PR_BLUE%~$UNBOLD $PR_LIGHT_BLUE`vcprompt -f "[%b] "`$PR_GREEN%#$PR_NO_COLOUR ' else PROMPT='$BOLD$PR_RED%n@%m:$PR_BLUE%~$UNBOLD $PR_GREEN%#$PR_NO_COLOUR ' #user@machine on front fi # PROMPT="__________________________________________________________________ # $BOLD$PR_BLUE%~$UNBOLD $PR_LIGHT_BLUE`vcprompt -f "[%b] "` # $PR_GREEN%#$PR_NO_COLOUR " # Prompt in right margin ## RPROMPT='[%h]' function title { if [[ $TERM == "screen" ]]; then # Use these two for GNU Screen: print -nR $'\033k'$1$'\033'\\\ print -nR $'\033]0;'$2$'\a' elif [[ "$is_mac" == yes ]]; then print -Pn "\e]1;$*\a" elif [[ $TERM == "xterm*" || $TERM == "rxvt" ]]; then # Use this one instead for XTerms: print -nR $'\033]0;'$*$'\a' fi } function precmd { title '%~' } function preexec { emulate -L zsh local -a cmd; cmd=(${(z)1}) title $cmd[1]:t "$cmd[2,-1]" } function tab() { osascript 2>/dev/null <