Skip to content

Instantly share code, notes, and snippets.

@mtigas
Forked from tkaemming/gist:94302
Created October 27, 2009 09:55
Show Gist options
  • Save mtigas/219443 to your computer and use it in GitHub Desktop.
Save mtigas/219443 to your computer and use it in GitHub Desktop.
.zshrc
# .zshrc
alias lstree="ls -R | grep \":$\" | sed -e 's/:$//' -e 's/[^-][^\/]*\//–/g' -e 's/^/ /' -e 's/-/|/'"
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_COLOR="%{$terminfo[sgr0]%}"
git_prompt_info() {
echo `ruby -e "print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '\1:')"`
}
setopt prompt_subst
PROMPT='%n %# '
RPROMPT='$PR_YELLOW$(git_prompt_info)$PR_GREEN%~% $PR_NO_COLOR'
site_packages() {
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
}
cleanpyc() {
# Deletes Python bytecode from common places and the current directory tree.
find ~/Code -name "*.pyc" -delete
find ~/Code -name "*.pyo" -delete
find . -name "*.pyc" -delete
find . -name "*.pyo" -delete
}
pack_code() {
# Packs OS X sparseimage and sparsebundle files in a couple of places. (I use 'em for encrypted storage.)
for i in `find ~/Code -name "*.sparse*"`
do
print
print $i
hdiutil compact -batteryallowed $i
done
for i in `find ~/Documents -name "*.sparse*"`
do
print
print $i
hdiutil compact -batteryallowed $i
done
}
alias s3up=~/Code/libs/s3up.py
alias s3dir=~/Code/libs/s3dir.py
alias flac2lame=~/Code/libs/flac2lame.py
alias aimpacketconvert=~/Code/libs/aimpacketconvert.py
alias 7z="/Applications/eZ\ 7z.app/Contents/Resources/7za"
alias 7za="/Applications/eZ\ 7z.app/Contents/Resources/7za"
alias 7z_make="7za a -ms=on -mx=9 -mmt=2 -t7z"
alias startmemcache="memcached -vv -m 1024 -l 127.0.0.1 -p 55838"
alias start_postgres="sudo -u postgres /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data start"
alias stop_postgres="sudo -u postgres /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data stop"
setcflags() {
export MACOSX_DEPLOYMENT_TARGET=10.6
export CFLAGS="-arch x86_64 -mtune=nocona -march=nocona -ffast-math -mfpmath=sse -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1"
export CXXFLAGS=$CFLAGS
export CPPFLAGS=$CFLAGS
export LDFLAGS="-arch x86_64"
}
watch() {
# Simulates the Linux "watch -n 1" command, sort of.
while x=0; do $*; sleep 1; done;
}
privoxy_settings() {
mate /usr/local/etc/privoxy
}
sniff() {
# Eavesdrop on unprotected wireless network.
# Runs TCPdump in promiscuous mode on this Mac's wireless card. Excludes 802.11 beacon packets and
# packets coming from this computer. Open resultant dump file in WireShark or other
# packet decoding programs.
sudo tcpdump -i en1 -I -n -w ~/Documents/PacketCapture/`date +"%Y%m%d-%H%M%S"`_$1.pcap not ether host 00:26:bb:0b:1e:99 and not host $2 and not "(wlan[0:1] & 0xfc) == 0x40" and not "(wlan[0:1] & 0xfc) == 0x80" and not "(wlan[0:1] & 0xfc) == 0xc4" and not "(wlan[0:1] & 0xfc) == 0xd4"
}
reset_capstone_servers() {
# For all three test servers (since I'm toying with load balancing and DB replication and cache spanning):
# touch wsgi file (to cause apache to notice updates)
# delete python bytecode
# pre-compile python .pyo bytecode
# restart memcached (clear the cache)
ssh -C 173.45.228.60 "touch wsgi/server_capstone.wsgi;find projects/cs4970_capstone.git/ -name \"*.pyc\" -delete;find projects/cs4970_capstone.git/ -name \"*.pyo\" -delete;python -O -c \"import compileall;compileall.compile_dir('projects/cs4970_capstone.git/',maxlevels=20,force=True,quiet=False)\";sudo service memcached restart"
ssh -C 173.45.237.207 "touch wsgi/capstone_wsgi.py;find projects/cs4970_capstone.git/ -name \"*.pyc\" -delete;find projects/cs4970_capstone.git/ -name \"*.pyo\" -delete;python -O -c \"import compileall;compileall.compile_dir('projects/cs4970_capstone.git/',maxlevels=20,force=True,quiet=False)\";sudo service memcached restart"
ssh -C 173.45.238.39 "touch wsgi/capstone_wsgi.py;find projects/cs4970_capstone.git/ -name \"*.pyc\" -delete;find projects/cs4970_capstone.git/ -name \"*.pyo\" -delete;python -O -c \"import compileall;compileall.compile_dir('projects/cs4970_capstone.git/',maxlevels=20,force=True,quiet=False)\";sudo service memcached restart"
if [[ -d /Volumes/cs4970_capstone ]]; then
echo "Updating media.nationbrowse.com..."
s3dir UPDATE_CAPSTONE
else
echo "Project bundle not open, skipping S3 update."
fi
}
replace_capstone_settings() {
# Deploy a new settings file to all three testing servers.
scp -C local_settings.py 173.45.228.60:projects/cs4970_capstone.git/django_server/server/nationbrowse/local_settings.py
scp -C local_settings.py 173.45.237.207:projects/cs4970_capstone.git/django_server/server/nationbrowse/local_settings.py
scp -C local_settings.py 173.45.238.39:projects/cs4970_capstone.git/django_server/server/nationbrowse/local_settings.py
reset_capstone_servers
}
export EDITOR=mate_wait
export SVN_EDITOR=mate_wait
export PYTHONOPTIMIZE=1
export PYTHONPATH="$HOME/Code/libs"
export PATH=/Library/Frameworks/Python.framework/Versions/2.6/bin:$PATH
export PATH=$HOME/Code/libs:$PATH
export PATH="/usr/local/pgsql/bin:$PATH"
export PATH=/Library/Frameworks/UnixImageIO.framework/Programs:$PATH
export PATH=/Library/Frameworks/PROJ.framework/Programs:$PATH
export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH
export PATH=$PATH:~/Library/_LocalApps/depot_tools
#export PATH=/opt/local/bin:/opt/local/sbin:$PATH
#export MANPATH=/opt/local/share/man:$MANPATH
setopt APPEND_HISTORY
setopt CORRECT
setopt EXTENDED_HISTORY
setopt HIST_ALLOW_CLOBBER
setopt HIST_REDUCE_BLANKS
setopt INC_APPEND_HISTORY
setopt ALL_EXPORT
setopt MENUCOMPLETE
setopt notify globdots correct pushdtohome cdablevars autolist
setopt correctall autocd recexact longlistjobs
setopt autoresume histignoredups pushdsilent noclobber
setopt autopushd pushdminus extendedglob rcquotes mailwarning
unsetopt bgnice autoparamslash
zmodload -a zsh/stat stat
zmodload -a zsh/zpty zpty
zmodload -a zsh/zprof zprof
zmodload -ap zsh/mapfile mapfile
HISTFILE=$HOME/.zhistory
HISTSIZE=10000
SAVEHIST=10000
PAGER='less'
autoload -U compinit
compinit
bindkey '^r' history-incremental-search-backward
bindkey "^[[5~" up-line-or-history
bindkey "^[[6~" down-line-or-history
bindkey "^[[H" beginning-of-line
bindkey "^[[1~" beginning-of-line
bindkey "^[[F" end-of-line
bindkey "^[[4~" end-of-line
bindkey ' ' magic-space # also do history expansion on space
bindkey '^I' complete-word # complete on tab, leave expansion to _expand
zstyle ':completion::complete:*' use-cache on
zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the character to insert%s'
zstyle ':completion:*' menu select=1 _complete _ignored _approximate
zstyle -e ':completion:*:approximate:*' max-errors \
'reply=( $(( ($#PREFIX+$#SUFFIX)/2 )) numeric )'
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
zstyle ':completion:*:processes' command 'ps -axw'
zstyle ':completion:*:processes-names' command 'ps -awxho command'
# Completion Styles
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
# list of completers to use
zstyle ':completion:*::::' completer _expand _complete _ignored _approximate
# allow one error for every three characters typed in approximate completer
zstyle -e ':completion:*:approximate:*' max-errors \
'reply=( $(( ($#PREFIX+$#SUFFIX)/2 )) numeric )'
# insert all expansions for expand completer
zstyle ':completion:*:expand:*' tag-order all-expansions
#
#NEW completion:
# 1. All /etc/hosts hostnames are in autocomplete
# 2. If you have a comment in /etc/hosts like #%foobar.domain,
# then foobar.domain will show up in autocomplete!
zstyle ':completion:*' hosts $(awk '/^[^#]/ {print $2 $3" "$4" "$5}' /etc/hosts | grep -v ip6- && grep "^#%" /etc/hosts | awk -F% '{print $2}')
# formatting and messages
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
zstyle ':completion:*' group-name ''
# match uppercase from lowercase
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# offer indexes before parameters in subscripts
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
# command for process lists, the local web server details and host completion
#zstyle ':completion:*:processes' command 'ps -o pid,s,nice,stime,args'
#zstyle ':completion:*:urls' local 'www' '/var/www/htdocs' 'public_html'
zstyle '*' hosts $hosts
# Filename suffixes to ignore during completion (except after rm command)
zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.c~' \
'*?.old' '*?.pro' '*?.pyc'
# the same for old style completion
#fignore=(.o .c~ .old .pro)
# ignore completion functions (until the _ignored completer)
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:scp:*' tag-order \
files users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
zstyle ':completion:*:scp:*' group-order \
files all-files users hosts-domain hosts-host hosts-ipaddr
zstyle ':completion:*:ssh:*' tag-order \
users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
zstyle ':completion:*:ssh:*' group-order \
hosts-domain hosts-host users hosts-ipaddr
zstyle '*' single-ignored show
bindkey "^[[3~" delete-char
alias screen='screen -U'
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment