Skip to content

Instantly share code, notes, and snippets.

@hamsolodev
Created August 1, 2013 23:30
Show Gist options
  • Save hamsolodev/6136271 to your computer and use it in GitHub Desktop.
Save hamsolodev/6136271 to your computer and use it in GitHub Desktop.
# -*- mode: sh; coding: utf-8 -*-
# check for interactive shell, returning straight away if this isn't
# one!
[ -z "$PS1" ] && return
setopt prompt_subst
setopt transient_rprompt
setopt prompt_sp
autoload -Uz vcs_info
autoload -U colors && colors
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' check-for-changes true
zstyle ':completion:*' completer _complete _ignored
## START options to make zsh completion more verbose
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:*' group-name
## END
autoload -Uz compinit
compinit
# emacs–like region killing
bindkey "\C-w" kill-region
## Make my prompt feedback more information.
precmd() {
# make it obvious if I'm root
if [[ "$EUID" = "0" ]] {
WOOT="%{%}%{$fg[red]%}%{%}#%{$reset_color%}"
} else {
WOOT=''
#'%%'
}
# am I in a virtualenv?
if [[ ! -z "$VIRTUAL_ENV" ]] {
VENV="%{$fg[red]%}[%{$reset_color%}v:%{$fg[blue]%}$(basename $VIRTUAL_ENV)%{$fg[red]%}]%{$reset_color%}
"
if [[ ! -z "$DJANGO_SETTINGS_MODULE" ]] {
DJ_SETTINGS="%{$fg[red]%}[%{$reset_color%}s:%{$fg[green]%}$DJANGO_SETTINGS_MODULE%{$reset_color%}%{$fg[red]%}]%{$reset_color%}
"
} else {
DJ_SETTINGS=""
}
} else {
VENV=""
DJ_SETTINGS=""
}
## Git stuff
# is there anything in the stash?
if [[ -z $(git stash list 2> /dev/null) ]] {
STASH=""
} else {
STASH="%f,%F{yellow}S%f"
}
# are there any untracked files hanging around?
if [[ -z $(git ls-files --other --exclude-standard 2> /dev/null) ]] {
zstyle ':vcs_info:*' formats '%F{magenta}[%F{green}%b%u${STASH}%F{magenta}]%f'
zstyle ':vcs_info:*' actionformats '%F{magenta}[%F{green}%b%u${STASH}%F{magenta}]%f'
} else {
zstyle ':vcs_info:*' formats "%F{magenta}[%F{green}%b%u%F{red}+%F${STASH}%F{magenta}]%f"
zstyle ':vcs_info:*' actionformats "%F{magenta}[%F{green}%b%u%F{red}+${STASH}%F{magenta}]%f"
}
vcs_info
RPROMPT="%~ ${vcs_info_msg_0_}"
PROMPT="${VENV}${DJ_SETTINGS}%{$fg[green]%}%m> %{$reset_color%}${WOOT}"
}
alias emacs='/usr/local/bin/emacs -nw'
alias ec='/usr/local/bin/emacsclient'
alias elisp='/usr/local/bin/emacs --script'
alias ls='gls --colo=auto -F'
#alias clj='/usr/local/bin/rlwrap /usr/local/bin/clj'
alias idle='python -m idlelib.idle'
alias more='less'
alias cat='/usr/local/bin/src-hilite-lesspipe.sh'
alias behave='behave --no-source'
alias pin='pip install'
alias pun='pip uninstall'
alias fucking='sudo'
alias racket='rlwrap racket'
#
## Set a lot of env. vars…they're exported later.
#
EDITOR='/usr/local/bin/emacsclient'
NODE_PATH=/usr/local/lib/node_modules
PATH=$PATH:/usr/local/share/npm/bin:/Applications/VMware\ Fusion.app/Contents/Library/
# python virtualenv
WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
# python pip package cache
PIP_DOWNLOAD_CACHE="${HOME}/.pip_cache/"
# this ensures that whatever JVM is selected in system preferences is used.
JAVA_HOME=`/usr/libexec/java_home`
# DrRacket etc.
PATH=$PATH:/Applications/Racket\ v5.3.2/bin
#ARCHFLAGS="-arch i386 -arch x86_64"
ARCHFLAGS="-arch x86_64"
#PYTHONDONTWRITEBYTECODE="NOPE!"
PYTHONSTARTUP=$HOME/.pystartup.py
# when paging files using 'less', this syntax highlights them!
LESSOPEN="| /usr/local/bin/src-hilite-lesspipe.sh %s"
LESS=" -R "
# override to put /usr/local/bin first for Homebrew
PATH=/usr/local/bin:$HOME/Documents/bin:$PATH:/usr/local/texlive/2012/bin/x86_64-darwin:/usr/local/sbin
WORDCHARS='*?_-.[]~&;!#$%^(){}<>'
export WORDCHARS
export PATH MANTA_URL
export EDITOR WORKON_HOME PIP_DOWNLOAD_CACHE JAVA_HOME HOMEBREW_USE_GCC
export ARCHFLAGS NODE_PATH PYTHONDONTWRITEBYTECODE LSCOLORS LESSOPEN LESS
export PYTHONSTARTUP
# update an active virtualenv's etags—to be used after installing
# packages inside the virtualenv.
function venvtags {
if [[ ! -z "$VIRTUAL_ENV" ]] {
echo Running etags on virtualenv dir…
find -L $VIRTUAL_ENV -type f -name "*.py" | xargs etags -o $VIRTUAL_ENV/TAGS
} else {
echo Not in a virtualenv
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment