+function __ps1_bg() {
+ [ "$__ps1_bg" = "1" ] || return $1
+ local job
+ local running=0; for job in $(builtin jobs -pr); do running=$((running+1)); done
+ local total=0; for job in $(builtin jobs -p); do total=$((total+1)); done
+ [ $total = 0 ] && return $1
+ if [ -z "$2" ]; then
+ [ "$__ps1_user" = "1" ] && echo -n " "
+ echo -n "["
+ [ $running = $total ] || echo -n "$running/"
+ echo -n "$total]"
+ else
+ echo $2
+ fi
+ return $1
+}
+
+function __ps1_colon() {
+ local all="$__ps1_user$__ps1_git$__ps1_p4$__ps1_svn$(__ps1_bg $1 1)"
+ [ "${all/1/}" = "$all" ] || echo -n ":"
+ return $1
+}
+
+function __ps1_short() {
+ local home=${HOME%%/}
+ local pwd=${PWD/#$home/\~}
+ local dirtrim=${PROMPT_DIRTRIM//[^0-9]/}
+
+ if [ "${dirtrim:0:1}" = "0" ]; then
+ echo "$pwd"
+ return $1
+ fi
+
+ dirtrim=${dirtrim##0}
+ if [ -z "$dirtrim" ]; then
+ local prompt="$USER$HOSTNAME$pwd"
+ local width=$(((COLUMNS*2)/3))
+ if [ ${#prompt} -le ${width:-53} ]; then
+ echo "$pwd"
+ return $1
+ else
+ dirtrim=1
+ fi
+ fi
+
+ local dirname=${pwd##*/}
+ local basename=${pwd%/$dirname}
+ local reversed=
+ local component
+ for component in ${basename//\// }; do
+ reversed="$component $reversed"
+ done
+ local n=1
+ local short=
+ for component in $reversed; do
+ [ $n = 1 -a "$PWD" = "$pwd" ] || short="/$short"
+ if [ $n -ge $dirtrim ]; then
+ short="${component:0:1}$short"
+ else
+ short="$component$short"
+ fi
+ n=$((n+1))
+ done
+
+ echo "$short$dirname"
+ return $1
+}
+