Created
July 19, 2012 16:13
-
-
Save bonjourmauko/3145007 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
| #------------------------------------------------------------------------------ | |
| # Returncode. | |
| #------------------------------------------------------------------------------ | |
| function returncode | |
| { | |
| returncode=$? | |
| if [ $returncode != 0 ]; then | |
| echo "[$returncode]" | |
| else | |
| echo "" | |
| fi | |
| } | |
| #------------------------------------------------------------------------------ | |
| # Prompt. | |
| #------------------------------------------------------------------------------ | |
| if [ "$BASH" ]; then | |
| if [ "`id -u`" -eq 0 ]; then | |
| # The root prompt is red. | |
| PS1='\[\033[0;31m\]\u@\h:\w >\[\033[0;37m\] ' | |
| else | |
| # PS1='\u@\h:\w > ' | |
| PS1='\[\033[0;31m\]$(returncode)\[\033[0;37m\]\[\033[0;35m\]\u@\h\[\033[0;37m\]:\[\033[0;36m\]\w\[\033[0;37m\]$(parse_git_branch) > ' | |
| fi | |
| else | |
| if [ "`id -u`" -eq 0 ]; then | |
| PS1='# ' | |
| else | |
| PS1='$ ' | |
| fi | |
| fi | |
| export PS1 | |
| PROMPT_COMMAND='history -a' | |
| #------------------------------------------------------------------------------ | |
| # Git options. | |
| #------------------------------------------------------------------------------ | |
| function parse_git_dirty { | |
| [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
| } | |
| function parse_git_branch { | |
| git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" | |
| } | |
| #------------------------------------------------------------------------------ | |
| # Colorized ls. | |
| #------------------------------------------------------------------------------ | |
| export LS_OPTIONS='--color=auto' | |
| alias ls='ls $LS_OPTIONS' | |
| #------------------------------------------------------------------------------ | |
| # Terminal settings. | |
| #------------------------------------------------------------------------------ | |
| if ! [ $TERM ] ; then | |
| eval `tset -s -Q` | |
| case $TERM in | |
| con*|vt100|linux|xterm) | |
| tset -Q -e ^? | |
| ;; | |
| esac | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment