Created
October 20, 2010 13:54
-
-
Save farhaven/636452 to your computer and use it in GitHub Desktop.
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
#!/bin/mksh | |
[ -z "$PS1" ] && return | |
# {{{ prompt | |
# {{{ is_scm_dir | |
is_scm_dir() | |
{ | |
if [ -d $2/.$1 ]; then | |
return 0 | |
elif [ $2 == "/" ]; then | |
return 1 | |
fi | |
is_scm_dir $1 $(dirname $2) | |
return $? | |
} | |
# }}} | |
# {{{ scm_branch | |
scm_branch() | |
{ | |
if is_scm_dir git $(pwd); then | |
branch=$(git branch | grep -e '^\*' | cut -d ' ' -f 2) | |
echo "(git)(${branch}) " | |
return 0 | |
fi | |
if is_scm_dir hg $(pwd); then | |
branch=$(hg branch) | |
echo "(hg)(${branch}) " | |
return 0 | |
fi | |
if is_scm_dir svn $(pwd); then | |
branch=$(svn info | grep ^Rev | cut -d' ' -f2) | |
echo "(svn)(${branch}) " | |
return 0 | |
fi | |
if is_scm_dir bzr $(pwd) ; then | |
branch=$(bzr log | grep '^rev' | head -n1 | cut -d' ' -f2) | |
echo "(bzr)(${branch}) " | |
return 0 | |
fi | |
return 1 | |
} | |
# }}} | |
# {{{ neatpwd | |
function neatpwd { | |
typeset d=${PWD:-?} n p=~; | |
[[ $p = ?(*/) ]] || d=${d/#$p/~} | |
(( ${#d} > (n = (COLUMNS/3 < 7 ? 7 : COLUMNS/3)) )) && { | |
d=${d:(-n)}; | |
p=...; | |
} || p=; | |
print -nr -- "$p$d" | |
} | |
# }}} | |
# {{{ color | |
function color { | |
echo -n "\e[$1;${2}m" | |
shift 2 | |
echo "$@\e[00m" | |
} | |
# }}} | |
PS1='$(color 01 33 "(`date +%H:%M:%S`)") $(color 01 34 `neatpwd`) $(color 01 30 `scm_branch`)' | |
if (( USER_ID )); then | |
PS1="$PS1$ " | |
else | |
PS1="$PS1# " | |
fi | |
# }}} | |
# {{{ aliases | |
alias ls='ls --color=auto' | |
alias la='ls -a' | |
alias ll='ls -lh' | |
alias rm='rm -rf' | |
alias rcp='rsync -r --size-only --progress' | |
alias vi='vim' | |
alias less='less -r' | |
alias ..='cd ..' | |
alias cdrecord='cdrecord -verbose' | |
alias gently='nice -n 20 ionice -c 3' | |
# }}} | |
# {{{ history | |
export HISTSIZE=200000 | |
export HISTFILE=~/.history | |
# }}} | |
# {{{ env vars | |
PATH=/usr/lib/ccache/bin:${HOME}/bin:${PATH} | |
PATH=${PATH}:/usr/sbin | |
export PATH=${PATH}:/usr/local/games:/sbin | |
export BROWSER=$HOME/bin/mimehandler | |
export EDITOR=vim | |
# export LC_ALL=de_DE.UTF-8 | |
# export LC_CTYPE=de_DE.UTF-8 | |
export LANG=de_DE.UTF-8 | |
export DOOMWADDIR=~/.zdoom | |
export LUA_PATH="${HOME}/.lua/?.lua;$(strings /usr/lib/liblua.so | grep init.lua)" | |
export GOROOT=~/sourcecode/go | |
export GOBIN=~/bin | |
export GOOS=linux | |
export GOARCH=386 | |
export GTK2_RC_FILES="/home/gregor/.gtkrc.mine" | |
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" | |
# }}} | |
# {{{ window size change handler | |
function update_winsize { | |
export COLUMNS=`stty -a | grep -oe 'columns [0-9]\+' | cut -d' ' -f2` | |
export ROWS=`stty -a | grep -oe 'rows [0-9]\+' | cut -d' ' -f2` | |
} | |
trap update_winsize 28 # 28 is SIGWINCH | |
update_winsize | |
# }}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment