Skip to content

Instantly share code, notes, and snippets.

@kennethreitz
Created April 25, 2010 20:38
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kennethreitz/378708 to your computer and use it in GitHub Desktop.
Save kennethreitz/378708 to your computer and use it in GitHub Desktop.
My environment configuration
alias ports='sudo lsof -iTCP -sTCP:LISTEN -P'
alias dnsflush='dscacheutil -flushcache'
alias git-add='git add -A'
alias dmesg="sudo dmesg"
alias l='ls -lrtha'
alias dir='ls -lh'
alias svnscrub='find . -name .svn -exec rm -rf {} \;'
alias vpnfix='sudo route -nv add -net 10 -interface utun0 && sudo route change default 10.0.1.1'
alias gitx='/Applications/GitX.app/Contents/MacOS/GitX &'
alias myip='curl -s http://whatismyip.org/'
alias top='htop
alias serve='python -m SimpleHTTPServer'
alias tab=new_terminal_working_directory
function new_terminal_working_directory() {
osascript <<END
tell application "Terminal"
tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
do script "cd $(pwd)" in first window
end tell
END
}
function git(){hub "$@"}
[user]
name = Kenneth Reitz
email = me@kennethreitz.com
[github]
token = xxxxxxxxxxxxxxxxxxx
user = kennethreitz
.*.swp
tags
.swo
.DS_Store
.*.pyc
*.scratch.*
.svn
source ~/bin/git-completion.bash
set nocompatible
syntax on
filetype plugin indent on
set autoindent
set tabstop=4
set shiftwidth=4
set expandtab
set laststatus=2
" Maps autocomplete to tab
imap <Tab> <C-N>
git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null)
if [[ -n $ref ]]; then
echo "[%{$fg_bold[green]%}${ref#refs/heads/}%{$reset_color%}]"
fi
}
# makes color constants available
autoload -U colors
colors
# enable colored output from ls, etc
export CLICOLOR=1
# expand functions in the prompt
setopt prompt_subst
# prompt
export PS1='$(git_prompt_info)[${SSH_CONNECTION+"%{$fg_bold[green]%}%n@%m:"}%{$fg_bold[blue]%}%~%{$reset_color%}] '
# autocompletion for ruby_test
# works with tu/tf aliases
_ruby_tests() {
if [[ -n $words[2] ]]; then
compadd `ruby_test -l ${words[2]}`
fi
}
compdef _ruby_tests ruby_test
# autocompletion for ruby_tu_rs
# works with su/sf aliases
_ruby_mixed_tests() {
if [[ -n $words[2] ]]; then
compadd `ruby_tu_rs -l ${words[2]}`
fi
}
compdef _ruby_mixed_tests ruby_tu_rs
_git_remote_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null)
if [[ -n $ref ]]; then
if (( CURRENT == 2 )); then
# first arg: operation
compadd create publish rename delete track
elif (( CURRENT == 3 )); then
# second arg: remote branch name
compadd `git branch -r | grep -v HEAD | sed "s/.*\///" | sed "s/ //g"`
elif (( CURRENT == 4 )); then
# third arg: remote name
compadd `git remote`
fi
else;
_files
fi
}
compdef _git_remote_branch grb
# autocompletion for schema
_rails_tables() {
if [[ -n $words[2] ]]; then
compadd `schema -l ${words[2]}`
fi
}
compdef _rails_tables schema
zmodload zsh/complist
autoload -U compinit && compinit
_force_rehash() {
(( CURRENT == 1 )) && rehash
return 1 # Because we didn't really complete anything
}
zstyle ':completion:::::' completer _force_rehash _complete _approximate
zstyle -e ':completion:*:approximate:*' max-errors 'reply=( $(( ($#PREFIX + $#SUFFIX) / 3 )) )'
zstyle ':completion:*:descriptions' format "- %d -"
zstyle ':completion:*:corrections' format "- %d - (errors %e})"
zstyle ':completion:*:default' list-prompt '%S%M matches%s'
zstyle ':completion:*' group-name ''
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*:manuals.(^1*)' insert-sections true
zstyle ':completion:*' menu select
zstyle ':completion:*' verbose yes
# completion
autoload -U compinit
compinit
# automatically enter directories without cd
setopt auto_cd nobeep listpacked nocheckjobs alwaystoend sharehistory
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
# use vim as an editor
export EDITOR=mate
PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin/:$PATH"
PATH="/System/Library/Frameworks/Grails.framework/Current/bin/:$PATH"
PATH="/usr/local/homebrew/bin/:$PATH"
PATH="/usr/local/homebrew/sbin/:$PATH"
export GISTY_DIR="/Users/kreitz/repos/gists/"
zstyle ':completion:*' hosts $(awk '/^[^#]/ {print $2 $3" "$4" "$5}' /etc/hosts | grep -v ip6- && grep "^#%" /etc/hosts | awk -F% '{print $2}')
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
zstyle ':completion:*:processes' command 'ps -o pid,s,nice,stime,args'
zstyle ':completion:*:urls' local 'www' '/var/www/htdocs' 'Sites'
zstyle '*' hosts $hosts
zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.c~' \
'*?.old' '*?.pro' '*?.pyc' '.svn'
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
# aliases
if [ -e "$HOME/.aliases" ]; then
source "$HOME/.aliases"
fi
# vi mode
bindkey -v
# use incremental search
bindkey '^r' history-incremental-search-backward
# expand functions in the prompt
setopt prompt_subst
# prompt
export PS1='[${SSH_CONNECTION+"%n@%m:"}%~] '
# ignore duplicate history entries
setopt histignoredups
# keep more history
export HISTSIZE=200000000
#compdef brew
# Brew ZSH completion function
# Drop this somewhere in your $fpath (like /usr/share/zsh/site-functions)
# *** /opt/local/share/zsh/4.2.7/functions
# and rename it _brew
#
# altered from _fink
_brew_all_formulae() {
formulae=(`brew search`)
}
_brew_installed_formulae() {
installed_formulae=(`brew list`)
}
local -a _1st_arguments
_1st_arguments=(
'install:install a formula'
'remove:remove a formula'
'search:search for a formula (/regex/ or string)'
'list:list files in a formula or not-installed formulae'
'link:link a formula'
'unlink:unlink a formula'
'home:visit the homepage of a formula or the brew project'
'info:information about a formula'
'prune:remove dead links'
'update:freshen up links'
'log:git commit log for a formula'
'create:create a new formula'
'edit:edit a formula'
'uses:show formulas which depend on a formula'
'outdated:list formulas for which a newer version is available'
'cleanup:uninstall unused and old versions of packages'
'deps:list dependencies and dependants of a formula'
'cat:display formula file for a formula'
)
local expl
local -a formula installed_formulae
_arguments \
'(-v --verbose)'{-v,--verbose}'[verbose]' \
'(--version)--version[version information]' \
'(--prefix)--prefix[where brew lives on this system]' \
'(--cache)--cache[brew cache]' \
'*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then
_describe -t commands "brew subcommand" _1st_arguments
return
fi
case "$words[1]" in
list)
_arguments \
'(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
'1: :->forms' && return 0
if [[ "$state" == forms ]]; then
_brew_installed_formulae
_requested installed_formulae expl 'installed formulae' compadd -a installed_formulae
fi ;;
install|home|log|info|uses|cat|deps)
_brew_all_formulae
_wanted formulae expl 'all formulae' compadd -a formulae ;;
remove|edit|xo)
_brew_installed_formulae
_wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment