Created
May 21, 2013 19:45
-
-
Save assaf/5622619 to your computer and use it in GitHub Desktop.
.bashrc
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
# ---------------------------------------------------------------------- | |
# SHELL OPTIONS | |
# ---------------------------------------------------------------------- | |
# notify of bg job completion immediately | |
set -o notify | |
# Prevents history expansion, so commit -m "Yay!" will work. | |
set +o histexpand | |
# Warn when trying to overwrite file. | |
set -o noclobber | |
# shell opts. see bash(1) for details | |
shopt -s cdspell >/dev/null 2>&1 | |
shopt -s extglob >/dev/null 2>&1 | |
shopt -s histappend >/dev/null 2>&1 | |
shopt -s hostcomplete >/dev/null 2>&1 | |
shopt -s interactive_comments >/dev/null 2>&1 | |
shopt -u mailwarn >/dev/null 2>&1 | |
shopt -s no_empty_cmd_completion >/dev/null 2>&1 | |
# fuck that you have new mail shit | |
unset MAILCHECK | |
# disable core dumps | |
ulimit -S -c 0 | |
# default umask | |
umask 0022 | |
# ---------------------------------------------------------------------- | |
# ENVIRONMENT CONFIGURATION | |
# ---------------------------------------------------------------------- | |
# we want the various sbins on the path along with /usr/local/bin | |
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/bin:/usr/local/sbin:/usr/local/share/npm/bin:$HOME/bin:$PATH" | |
# enable en_US locale w/ utf-8 encodings if not already configured | |
: ${LANG:="en_US.UTF-8"} | |
: ${LANGUAGE:="en"} | |
: ${LC_CTYPE:="en_US.UTF-8"} | |
: ${LC_ALL:="en_US.UTF-8"} | |
export LANG LANGUAGE LC_CTYPE LC_ALL | |
# always use PASSIVE mode ftp | |
: ${FTP_PASSIVE:=1} | |
export FTP_PASSIVE | |
# ignore backups, CVS directories, python bytecode, vim swap files | |
FIGNORE="~:CVS:#:.pyc:.swp:.swa:apache-solr-*:.rbc" | |
HISTCONTROL=ignoreboth | |
export MANPATH=/usr/local/share/man:$MANPATH | |
export CLICOLOR=cons25 | |
# ---------------------------------------------------------------------- | |
# PAGER / EDITOR | |
# ---------------------------------------------------------------------- | |
# EDITOR | |
export EDITOR="vim -f" | |
#export EDITOR='mvim -f --nomru -c "au VimLeave * !open -a Terminal"' | |
export PAGER="less -FirSwX" | |
export MANPAGER="less -FiRswX" | |
# ---------------------------------------------------------------------- | |
# PROMPT | |
# ---------------------------------------------------------------------- | |
RED="[033[0;31m]" | |
BROWN="[033[0;33m]" | |
GREY="[033[0;97m]" | |
BLUE="[033[0;34m]" | |
PS_CLEAR="[033[0m]" | |
SCREEN_ESC="[033k033134]" | |
if [ "$LOGNAME" = "root" ]; then | |
COLOR1="${RED}" | |
COLOR2="${BROWN}" | |
P="#" | |
else | |
COLOR1="${BLUE}" | |
COLOR2="${BROWN}" | |
P="$" | |
fi | |
prompt_simple() { | |
PS1='\W/$(parse_git_branch)$ ' | |
PS2="> " | |
} | |
prompt_compact() { | |
PS1="${COLOR1}${P}${PS_CLEAR} " | |
PS2="> " | |
} | |
prompt_color() { | |
PS1="${GREY}[${COLOR1}u${GREY}@${COLOR2}h${GREY}:${COLOR1}W${GREY}]${COLOR2}$P${PS_CLEAR} " | |
PS2="[[33;1m]continue [[0m[1m]> " | |
} | |
# Make a simple command-line prompt: PWD $ | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* (.*)/ (1)/' | |
} | |
# Use the color prompt by default when interactive | |
test -n "$PS1" && prompt_simple | |
# Show current working directory in window/tab name. | |
export PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}\007"' | |
# ---------------------------------------------------------------------- | |
# ALIASES / FUNCTIONS | |
# ---------------------------------------------------------------------- | |
# Quick calculator. | |
calc(){ awk "BEGIN{ print $* }" ;} | |
# Prevents the accidental deletion of files (remove, move, copy or > into existing file). | |
alias rm='rm -i' | |
alias cp='cp -i' | |
alias mv='mv -i' | |
# ---------------------------------------------------------------------- | |
# BASH COMPLETION | |
# ---------------------------------------------------------------------- | |
if test -z "$BASH_COMPLETION" ; then | |
bash=${BASH_VERSION%.*}; bmajor=${bash%.*}; bminor=${bash#*.} | |
if [ "$PS1" ] && [ $bmajor -gt 1 ] ; then | |
# search for a bash_completion file to source | |
for f in /usr/pkg/etc/back_completion /usr/local/etc/bash_completion /etc/bash_completion ~/.bash_completion ; | |
do | |
test -f $f && { | |
. $f | |
break | |
} | |
done | |
fi | |
unset bash bmajor bminor | |
fi | |
if [ -f /usr/local/etc/bash_completion ]; then | |
. /usr/local/etc/bash_completion | |
fi | |
# override and disable tilde expansion | |
_expand() { | |
return 0 | |
} | |
# ---------------------------------------------------------------------- | |
# LS AND DIRCOLORS | |
# ---------------------------------------------------------------------- | |
# we always pass these to ls(1) | |
LS_COMMON="-ahBG" | |
# if the dircolors utility is available, set that up to | |
dircolors="$(type -P gdircolors dircolors | head -1)" | |
test -n "$dircolors" && { | |
COLORS=/etc/DIR_COLORS | |
test -e "/etc/DIR_COLORS.$TERM" && COLORS="/etc/DIR_COLORS.$TERM" | |
test -e "$HOME/.dircolors" && COLORS="$HOME/.dircolors" | |
test ! -e "$COLORS" && COLORS= | |
eval `$dircolors --sh $COLORS` | |
} | |
unset dircolors | |
# setup the main ls alias if we've established common args | |
test -n "$LS_COMMON" && | |
alias ls="command ls $LS_COMMON" | |
# these use the ls aliases above | |
alias ll="ls -l" | |
alias l.="ls -d .*" | |
# ---------------------------------------------------------------------- | |
# RUBY RELATED | |
# ---------------------------------------------------------------------- | |
# For Ruby. | |
export RI="-T -fansi" | |
export RDOC='--no-ri' | |
# ---------------------------------------------------------------------- | |
# NODE.JS | |
# ---------------------------------------------------------------------- | |
export NODE_PATH="/usr/local/share/npm/lib/node_modules" | |
export PATH="./node_modules/.bin:$PATH" | |
# ---------------------------------------------------------------------- | |
# JVYUCK RELATED | |
# ---------------------------------------------------------------------- | |
export JAVA_HOME=/Library/Java/Home | |
export JAVA_OPTS=-client | |
# ---------------------------------------------------------------------- | |
# AWS | |
# ---------------------------------------------------------------------- | |
export EC2_PRIVATE_KEY=~/.ec2/pk-JAMKM3UNIAUXXJQYG53H3BDQ6ABQKTN3.pem | |
export EC2_CERT=~/.ec2/cert-JAMKM3UNIAUXXJQYG53H3BDQ6ABQKTN3.pem | |
# Load all files in .bash.d | |
for f in ~/.bash.d/* ; do | |
source $f | |
done | |
###-begin-npm-completion-### | |
# | |
# npm command completion script | |
# | |
# Installation: npm completion >> ~/.bashrc (or ~/.zshrc) | |
# Or, maybe: npm completion > /usr/local/etc/bash_completion.d/npm | |
# | |
COMP_WORDBREAKS=${COMP_WORDBREAKS/=/} | |
COMP_WORDBREAKS=${COMP_WORDBREAKS/@/} | |
export COMP_WORDBREAKS | |
if complete &>/dev/null; then | |
_npm_completion () { | |
local si="$IFS" | |
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \ | |
COMP_LINE="$COMP_LINE" \ | |
COMP_POINT="$COMP_POINT" \ | |
npm completion -- "${COMP_WORDS[@]}" \ | |
2>/dev/null)) || return $? | |
IFS="$si" | |
} | |
complete -F _npm_completion npm | |
elif compctl &>/dev/null; then | |
_npm_completion () { | |
local cword line point words si | |
read -Ac words | |
read -cn cword | |
let cword-=1 | |
read -l line | |
read -ln point | |
si="$IFS" | |
IFS=$'\n' reply=($(COMP_CWORD="$cword" \ | |
COMP_LINE="$line" \ | |
COMP_POINT="$point" \ | |
npm completion -- "${words[@]}" \ | |
2>/dev/null)) || return $? | |
IFS="$si" | |
} | |
compctl -K _npm_completion npm | |
fi | |
###-end-npm-completion-### | |
### Added by the Heroku Toolbelt | |
export PATH="/usr/local/heroku/bin:$PATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment