[Assorted-commits] SF.net SVN: assorted:[1537] shell-tools/trunk/src/bash-commons/bashrc.bash
Brought to you by:
yangzhang
From: <yan...@us...> - 2009-12-31 00:59:36
|
Revision: 1537 http://assorted.svn.sourceforge.net/assorted/?rev=1537&view=rev Author: yangzhang Date: 2009-12-31 00:59:26 +0000 (Thu, 31 Dec 2009) Log Message: ----------- new PS1 prompt shows exit status, git status, date/time; fixed asd, aoe; updated for renamed colors Modified Paths: -------------- shell-tools/trunk/src/bash-commons/bashrc.bash Modified: shell-tools/trunk/src/bash-commons/bashrc.bash =================================================================== --- shell-tools/trunk/src/bash-commons/bashrc.bash 2009-12-31 00:57:00 UTC (rev 1536) +++ shell-tools/trunk/src/bash-commons/bashrc.bash 2009-12-31 00:59:26 UTC (rev 1537) @@ -226,12 +226,12 @@ # switch to Dvorak function asd { - use-dvorak-keyboard + dvorak } # switch from Dvorak function aoe { - use-normal-keyboard + qwerty } # unison on home directory @@ -326,7 +326,7 @@ # TODO fix function g { #grep --color=always -r "$@" | sed "$( echo -e "s/\([^:]*\):/$bright_blue\1$normal_color:/" )" | less -F - grep --color=always -r "$@" | GREP_COLOR="$( echo -e "\e$bright_blue" )" grep --color=always -r '^[^:]*:' | less -F + grep --color=always -r "$@" | GREP_COLOR="$( echo -e "$fg_bright_blue" )" grep --color=always -r '^[^:]*:' | less -F } function runemacs { @@ -744,6 +744,37 @@ eval "$( dircolors -b )" +setup_prompt() { + # TODO add elapsed time, running jobs + + # Current date and time + local datetime="\[$fg_dark_gray\]\d \t\[$normal_color\]" + local elapsed= + + # Screen name (if inside a screen) + local screenname + if [ -n "$STY" ] + then screenname="\[$fg_dark_cyan\]$STY\[$normal_color\]" + else screenname= + fi + + # Display status on failure + local exitstatus='$( status=$? + if [ $status != 0 ] + then echo '"$(quote "\[$bg_dark_red\]")\$status$(quote "\[$normal_color\] ")"' + fi )' + + local user_host="\[$fg_dark_green\]\u@\h\[$normal_color\]" + local path="\[$fg_brown\]\w\[$normal_color\]" + local git_ps1="\[$fg_yellow\]\$( __git_ps1 'git(%s) ' )\[$normal_color\]" + + PS1="$titlebar\n$user_host $exitstatus$datetime $path $git_ps1\n\$ " + + # \[\] is for PS1/PS2 only; lets bash calculate word wrapping correctly. + # it's not for general terminal usage. + # <http://www.ibm.com/developerworks/linux/library/l-tip-prompt/> +} + # -t 1 checks if fd 1 (stdout) is a terminal; if so then we're running # interactively. if [[ -t 1 ]] @@ -774,7 +805,6 @@ # ;; #esac - # TODO add timetamp and elapsed time for previous command and any other - # info you can find (eg running jobs) - PS1="$titlebar\n\[$dark_green\]\u@\h \[$brown\]\w\n\[$normal_color\]$ " + setup_prompt + fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |