Created
October 13, 2011 04:55
-
-
Save alloy-d/1283421 to your computer and use it in GitHub Desktop.
It's a bashrc!
This file contains hidden or 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
### SYSTEM DEFAULTS {{{1 | |
if [ -f /etc/bashrc ]; then | |
source /etc/bashrc | |
fi | |
if [ -f /etc/bash_completion ]; then | |
source /etc/bash_completion | |
fi | |
### BASICS {{{1 | |
alias ls='ls --classify --color=auto' | |
# DE-specific generic open command | |
alias open='exo-open' | |
# editor function | |
edit() { | |
gvim $@ >/dev/null 2>&1 & | |
} | |
# language aliases | |
alias py='python2' | |
alias py3='python3' | |
alias rb='ruby' | |
# timestamp I use for notes files | |
alias notestamp='date +%y%m%d%H%M' | |
# tunnel a Mercurial server | |
alias sshg='ssh -R 8001:127.0.0.1:8001' | |
### ENVIRONMENT {{{1 | |
export EDITOR=vim | |
export PAGER=less | |
export BROWSER=chromium | |
export MANWIDTH=72 | |
export GOROOT=$HOME/sys/go | |
export GOBIN=$GOROOT/bin | |
export GOARCH=amd64 | |
export GOOS=linux | |
export CHICKEN_REPOSITORY="$HOME/sys/lib/chicken/5" | |
export CHICKEN_INSTALL_PREFIX="$HOME/sys" | |
export PERL5LIB="$HOME/lib/perl" | |
export PYTHONPATH="$HOME/lib/python" | |
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" | |
PATH="$HOME/sys/lib/perl/MultiMarkdown/bin:$PATH" | |
PATH="$HOME/.gem/ruby/1.9.1/bin:$PATH:/usr/lib/ruby/gems/1.9.1/bin" | |
PATH="$HOME/.cabal/bin:$PATH" | |
PATH="$GOBIN:$PATH" | |
PATH="$HOME/.cljr/bin:$PATH" | |
PATH="$HOME/sys/bin:$PATH:/usr/local/bin" | |
export PATH | |
### PROMPT SETUP {{{1 | |
prepare_prompt() { | |
WHITE="\[\033[1;37m\]" | |
GREEN="\[\033[1;32m\]" | |
CYAN="\[\033[1;36m\]" | |
GRAY="\[\033[1;30m\]" | |
BLUE="\[\033[1;34m\]" | |
RED="\[\033[1;31m\]" | |
NORMAL="\[\033[0m\]" | |
export HAPPY_FACE="${WHITE}(^_^)${NORMAL}" | |
export SAD_FACE="${RED}(O_O)${NORMAL}" | |
export PROMPT_INFO="${GREEN}\u${NORMAL}" | |
export PROMPT_PROMPT="${WHITE}\$${NORMAL}" | |
} | |
prepare_prompt | |
### VERSION CONTROL {{{1 | |
__vcs_info() { | |
local vcs base_dir sub_dir ref | |
sub_dir() { | |
local sub_dir | |
sub_dir=$(readlink -f "${PWD}") | |
sub_dir=${sub_dir#$1} | |
echo ${sub_dir#/} | |
} | |
git_dir() { | |
base_dir=$(git rev-parse --show-cdup 2>/dev/null) || return 1 | |
base_dir=$(readlink -f "$base_dir/..") | |
sub_dir=$(git rev-parse --show-prefix) | |
sub_dir=${sub_dir%/} | |
ref=$(git symbolic-ref -q HEAD || git-name-rev --name-only HEAD 2>/dev/null) | |
ref=${ref#refs/heads/} | |
vcs="git" | |
} | |
hg_dir() { | |
base_dir="." | |
while [ ! -d "$base_dir/.hg" ]; do | |
base_dir="$base_dir/.." | |
[ $(readlink -f "$base_dir") = "/" ] && return 1; | |
done | |
base_dir=$(readlink -f "$base_dir") | |
sub_dir=$(sub_dir "$base_dir") | |
if [ -f "$base_dir/.hg/branch" ]; then | |
ref=$(< "$base_dir/.hg/branch") | |
else | |
ref="default" | |
fi | |
vcs="hg" | |
} | |
git_dir || hg_dir || base_dir="$PWD" | |
echo -n "in ${BLUE}${PWD/$HOME/~}${NORMAL}${vcs:+ at ${CYAN}${ref}${NORMAL} via ${GREEN}${vcs}${NORMAL}}" | |
} | |
### PROMPT COMMAND | |
PROMPT_COMMAND='if [[ $? -eq 0 ]]; then FACE="$HAPPY_FACE"; else FACE="$SAD_FACE"; fi; export PS1="\n${FACE} ${PROMPT_INFO} $(__vcs_info)\n${PROMPT_PROMPT} "' | |
### RVM {{{1 | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" | |
alias rails2="rvm 1.9.1-p378@rails238" | |
alias rails3="rvm 1.9.2@rails31" | |
### SSH & GPG {{{1 | |
/usr/bin/keychain -Q -q ~/.ssh/id_dsa 99E101ED | |
[[ -f $HOME/.keychain/$(hostname)-sh ]] && source "$HOME/.keychain/$(hostname)-sh" | |
### MISC {{{1 | |
# juggler | |
jp() { | |
xlock -nolock -mode juggle -only balls -pattern "$*" | |
} | |
# vi:foldmethod=marker: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment