Created
November 10, 2012 14:20
-
-
Save codescv/4051243 to your computer and use it in GitHub Desktop.
zshrc
This file contains 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
# GistID: 4051243 | |
# The prompt | |
# enable color support of ls and also add handy aliases | |
setopt prompt_subst | |
autoload -U colors | |
colors | |
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]%}" | |
PS1='${PR_CYAN}${USERNAME}${PR_NO_COLOUR} ${PR_LIGHT_CYAN}%#${PR_NO_COLOUR} ' | |
RPS1='$PR_YELLOW%35<...<%~$PR_NO_COLOUR' | |
# Aliases | |
OS=`uname` | |
case $OS in | |
Linux) | |
alias ls='ls --color=auto';; | |
Darwin|FreeBSD) | |
alias ls='ls -G';; | |
esac | |
alias ll='ls -l' | |
alias la='ls -A' | |
alias l='ls -CF' | |
alias lla='ls -Al' | |
alias grep='egrep --color -i' | |
alias df='df -h' | |
# zsh specific settings | |
setopt nohup | |
setopt nobeep | |
setopt nohistbeep | |
setopt nolistbeep | |
bindkey -e | |
autoload -U compinit | |
autoload -U zcalc | |
compinit | |
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' | |
zstyle ':completion:*' expand 'yes' | |
zstyle ':completion:*' squeeze-shlashes 'yes' | |
zstyle ':completion::complete:*' '\\' | |
#eval $(dircolors -b) | |
#export ZLSCOLORS="${LS_COLORS}" | |
zmodload zsh/complist | |
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} | |
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' | |
compdef pkill=kill | |
compdef pkill=killall | |
zstyle ':completion:*:*:kill:*' menu yes select | |
zstyle ':completion:*:*:*:*:processes' force-list always | |
zstyle ':completion:*:processes' command 'ps -aux' | |
# make sudo perform properly | |
zstyle ':completion:*:sudo:*' command-path $path | |
# F1 calculator | |
arith-eval-echo() { | |
LBUFFER="${LBUFFER}echo \$(( " | |
RBUFFER=" ))$RBUFFER" | |
} | |
zle -N arith-eval-echo | |
bindkey "^[OP" arith-eval-echo | |
# [esc] [esc] to add sudo | |
sudo-command-line() { | |
[[ -z $BUFFER ]] && zle up-history | |
[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER" | |
zle end-of-line | |
} | |
zle -N sudo-command-line | |
bindkey "\e\e" sudo-command-line | |
# enviroment variables | |
ANDROID_SDK=~/Developer/adt-bundle/sdk | |
ANDROID_NDK=~/Developer/adt-bundle/ndk | |
export NDK=$ANDROID_NDK | |
ANDROID_PATH=$ANDROID_SDK/tools:$ANDROID_NDK:$ANDROID_SDK/platform-tools | |
PJPROJECT_PATH=~/Developer/pjproject/pjsip-apps/bin | |
ESSMSD_PATH=~/Developer/essmsd/bin | |
SCRIPTS_PATH=~/bin | |
PA=/usr/local/bin:/opt/local/bin:/opt/local/sbin:~/.local/bin | |
PZ=$ANDROID_PATH:$SCRIPTS_PATH:$ESSMSD_PATH:$NDK | |
export PATH=$PA:$PATH:$PZ | |
export EDITOR=vim | |
export PJSUA=$PJPROJECT_PATH/pjsua-i386-apple-darwin11.4.2 | |
export WORDCHARS='*?_-[]~=&;!#$%^(){}<>' | |
HISTSIZE=1000 | |
if (( ! EUID )); then | |
HISTFILE=~/.history_root | |
else | |
HISTFILE=~/.history | |
fi | |
SAVEHIST=1000 | |
# python | |
export PYTHONSTARTUP=~/.pythonrc | |
# Add RVM to PATH for scripting | |
RVM_PATH=~/.rvm | |
if [[ -d $RVM_PATH ]]; then | |
PATH=$PATH:$RVM_PATH/bin | |
source $RVM_PATH/scripts/rvm | |
rvm default | |
fi | |
# cd hooks | |
chpwd_functions=($chpwd_functions chpwd_hook) | |
CD_HOOK_FILE=".cd_hook" | |
chpwd_hook() { | |
if [[ -f $CD_HOOK_FILE ]]; then | |
echo "detected cd hook!" | |
source $CD_HOOK_FILE | |
fi | |
} | |
# grep shortcut | |
gr() { | |
if [[ -n "$2" ]]; then | |
find $(pwd) |grep "$2"|sed "s/\(.*\)/'\1'/"|xargs egrep --color -i $1 | |
else | |
find $(pwd) -print0 |xargs -0 egrep -i --color $1 | |
fi | |
} | |
# find file by name | |
ff() { | |
find $(pwd) -name "*$1*" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment