rjorgenson | e8a4e35 | 2011-06-17 06:13:55 -0700 | [diff] [blame] | 1 | # port of zork theme |
| 2 | |
rjorgenson | 2b4f94a | 2011-06-18 04:42:44 -0700 | [diff] [blame] | 3 | # set colors for use throughout the prompt |
| 4 | # i like things consistent |
rjorgenson | e305e48 | 2011-11-12 01:10:24 -0700 | [diff] [blame] | 5 | BRACKET_COLOR=${blue} |
| 6 | STRING_COLOR=${green} |
rjorgenson | 2b4f94a | 2011-06-18 04:42:44 -0700 | [diff] [blame] | 7 | |
rjorgenson | e8a4e35 | 2011-06-17 06:13:55 -0700 | [diff] [blame] | 8 | SCM_THEME_PROMPT_PREFIX="" |
| 9 | SCM_THEME_PROMPT_SUFFIX="" |
| 10 | |
rjorgenson | e305e48 | 2011-11-12 01:10:24 -0700 | [diff] [blame] | 11 | SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}" |
| 12 | SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}" |
| 13 | SCM_GIT_CHAR="${STRING_COLOR}±${normal}" |
| 14 | SCM_SVN_CHAR="${bold_cyan}⑆${normal}" |
| 15 | SCM_HG_CHAR="${bold_red}☿${normal}" |
rjorgenson | e8a4e35 | 2011-06-17 06:13:55 -0700 | [diff] [blame] | 16 | |
| 17 | #Mysql Prompt |
| 18 | export MYSQL_PS1="(\u@\h) [\d]> " |
| 19 | |
| 20 | case $TERM in |
| 21 | xterm*) |
| 22 | TITLEBAR="\[\033]0;\w\007\]" |
| 23 | ;; |
| 24 | *) |
| 25 | TITLEBAR="" |
| 26 | ;; |
| 27 | esac |
| 28 | |
| 29 | PS3=">> " |
| 30 | |
| 31 | __my_rvm_ruby_version() { |
| 32 | local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') |
| 33 | [ "$gemset" != "" ] && gemset="@$gemset" |
| 34 | local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') |
| 35 | local full="$version$gemset" |
rjorgenson | 2b4f94a | 2011-06-18 04:42:44 -0700 | [diff] [blame] | 36 | [ "$full" != "" ] && echo "${BRACKET_COLOR}[${STRING_COLOR}$full${BRACKET_COLOR}]${normal}" |
rjorgenson | e8a4e35 | 2011-06-17 06:13:55 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | is_vim_shell() { |
| 40 | if [ ! -z "$VIMRUNTIME" ] |
| 41 | then |
rjorgenson | e305e48 | 2011-11-12 01:10:24 -0700 | [diff] [blame] | 42 | echo "${BRACKET_COLOR}[${STRING_COLOR}vim shell${BRACKET_COLOR}]${normal}" |
rjorgenson | e8a4e35 | 2011-06-17 06:13:55 -0700 | [diff] [blame] | 43 | fi |
| 44 | } |
| 45 | |
rjorgenson | 0b218c4 | 2011-06-29 01:27:24 -0700 | [diff] [blame] | 46 | function is_integer() { # helper function for todo-txt-count |
| 47 | [ "$1" -eq "$1" ] > /dev/null 2>&1 |
| 48 | return $? |
| 49 | } |
| 50 | |
rjorgenson | a59d785 | 2011-06-17 23:28:57 -0700 | [diff] [blame] | 51 | todo_txt_count() { |
rjorgenson | 0b218c4 | 2011-06-29 01:27:24 -0700 | [diff] [blame] | 52 | if `hash todo.sh 2>&-`; then # is todo.sh installed |
| 53 | count=`todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }'` |
| 54 | if is_integer $count; then # did we get a sane answer back |
rjorgenson | e305e48 | 2011-11-12 01:10:24 -0700 | [diff] [blame] | 55 | echo "${BRACKET_COLOR}[${STRING_COLOR}T:$count${BRACKET_COLOR}]$normal" |
rjorgenson | 0b218c4 | 2011-06-29 01:27:24 -0700 | [diff] [blame] | 56 | fi |
| 57 | fi |
rjorgenson | a59d785 | 2011-06-17 23:28:57 -0700 | [diff] [blame] | 58 | } |
| 59 | |
rjorgenson | e8a4e35 | 2011-06-17 06:13:55 -0700 | [diff] [blame] | 60 | modern_scm_prompt() { |
| 61 | CHAR=$(scm_char) |
| 62 | if [ $CHAR = $SCM_NONE_CHAR ] |
| 63 | then |
| 64 | return |
| 65 | else |
rjorgenson | e305e48 | 2011-11-12 01:10:24 -0700 | [diff] [blame] | 66 | echo "${BRACKET_COLOR}[${CHAR}${BRACKET_COLOR}][${STRING_COLOR}$(scm_prompt_info)${BRACKET_COLOR}]$normal" |
rjorgenson | e8a4e35 | 2011-06-17 06:13:55 -0700 | [diff] [blame] | 67 | fi |
| 68 | } |
| 69 | |
rjorgenson | 2b4f94a | 2011-06-18 04:42:44 -0700 | [diff] [blame] | 70 | my_prompt_char() { |
rjorgenson | 35e1fe0 | 2011-07-08 06:26:22 -0700 | [diff] [blame] | 71 | if [[ $OSTYPE =~ "darwin" ]]; then |
| 72 | echo "${BRACKET_COLOR}➞ ${normal}" |
| 73 | else |
| 74 | echo "${BRACKET_COLOR}➞ ${normal}" |
| 75 | fi |
rjorgenson | 2b4f94a | 2011-06-18 04:42:44 -0700 | [diff] [blame] | 76 | } |
| 77 | |
rjorgenson | e8a4e35 | 2011-06-17 06:13:55 -0700 | [diff] [blame] | 78 | prompt() { |
| 79 | |
rjorgenson | 2b4f94a | 2011-06-18 04:42:44 -0700 | [diff] [blame] | 80 | my_ps_host="${STRING_COLOR}\h${normal}"; |
| 81 | my_ps_user="${STRING_COLOR}\u${normal}"; |
rjorgenson | a59d785 | 2011-06-17 23:28:57 -0700 | [diff] [blame] | 82 | my_ps_root="${bold_red}\u${normal}"; |
rjorgenson | 2b4f94a | 2011-06-18 04:42:44 -0700 | [diff] [blame] | 83 | my_ps_path="${STRING_COLOR}\w${normal}"; |
rjorgenson | e8a4e35 | 2011-06-17 06:13:55 -0700 | [diff] [blame] | 84 | |
| 85 | # nice prompt |
| 86 | case "`id -u`" in |
rjorgenson | 2b4f94a | 2011-06-18 04:42:44 -0700 | [diff] [blame] | 87 | 0) PS1="${TITLEBAR}${BRACKET_COLOR}┌─[$my_ps_root${BRACKET_COLOR}][$my_ps_host${BRACKET_COLOR}]$(modern_scm_prompt)$(__my_rvm_ruby_version)${BRACKET_COLOR}[${STRING_COLOR}\w${BRACKET_COLOR}]$(is_vim_shell) |
| 88 | ${BRACKET_COLOR}└─$(my_prompt_char)${normal}" |
rjorgenson | e8a4e35 | 2011-06-17 06:13:55 -0700 | [diff] [blame] | 89 | ;; |
rjorgenson | 2b4f94a | 2011-06-18 04:42:44 -0700 | [diff] [blame] | 90 | *) PS1="${TITLEBAR}${BRACKET_COLOR}┌─[$my_ps_user${BRACKET_COLOR}][$my_ps_host${BRACKET_COLOR}]$(modern_scm_prompt)$(__my_rvm_ruby_version)${BRACKET_COLOR}[${STRING_COLOR}\w${BRACKET_COLOR}]$(is_vim_shell) |
rjorgenson | 35e1fe0 | 2011-07-08 06:26:22 -0700 | [diff] [blame] | 91 | ${BRACKET_COLOR}└─$(todo_txt_count)$(my_prompt_char)" |
rjorgenson | e8a4e35 | 2011-06-17 06:13:55 -0700 | [diff] [blame] | 92 | ;; |
| 93 | esac |
| 94 | } |
| 95 | |
rjorgenson | 2b4f94a | 2011-06-18 04:42:44 -0700 | [diff] [blame] | 96 | PS2="└─$(my_prompt_char)" |
rjorgenson | e8a4e35 | 2011-06-17 06:13:55 -0700 | [diff] [blame] | 97 | |
| 98 | |
| 99 | |
| 100 | PROMPT_COMMAND=prompt |