# Default __ps1_user to 1.
[ -z "$__ps1_user" ] && __ps1_user=1
- PS1='\[\033[$(__ps1_background $?)m\]$(__ps1_user $? \u@)\[\033[$(__ps1_col $? 2>/dev/null)m\]$(__ps1_user $? \h)\[\033[$(__ps1_colour_escape $? $GIT_COLOUR $PROMPT_BACKGROUND_COLOUR)m\]$(__ps1_git $? 2>/dev/null)\[\033[0m\]\[\033[$(__ps1_colour_escape $? $P4_COLOUR $PROMPT_BACKGROUND_COLOUR)m\]$(__ps1_p4 $? 2>/dev/null)\[\033[0m\]\[\033[$(__ps1_colour_escape $? $SVN_COLOUR $PROMPT_BACKGROUND_COLOUR)m\]$(__ps1_svn $? 2>/dev/null)\[\033[$(__ps1_background $?)m\]$(__ps1_ret $? 2>/dev/null)$(__ps1_bg $?)$(__ps1_colon $?)\w\[\033[$(__ps1_root $? 2>/dev/null)m\]\$\[\033[0m\] '
+ PS1='\[\033[$(__ps1_background $?)m\]$(__ps1_user $? \u@)\[\033[$(__ps1_col $? 2>/dev/null)m\]$(__ps1_user $? \h)\[\033[$(__ps1_colour_escape $? $GIT_COLOUR $PROMPT_BACKGROUND_COLOUR)m\]$(__ps1_git $? 2>/dev/null)\[\033[0m\]\[\033[$(__ps1_colour_escape $? $P4_COLOUR $PROMPT_BACKGROUND_COLOUR)m\]$(__ps1_p4 $? 2>/dev/null)\[\033[0m\]\[\033[$(__ps1_colour_escape $? $SVN_COLOUR $PROMPT_BACKGROUND_COLOUR)m\]$(__ps1_svn $? 2>/dev/null)\[\033[$(__ps1_background $?)m\]$(__ps1_ret $? 2>/dev/null)$(__ps1_bg $?)$(__ps1_colon $?)$(__ps1_short $?)\[\033[$(__ps1_root $? 2>/dev/null)m\]\$\[\033[0m\] '
return 0
}
return $1
}
+function __ps1_short() {
+ local dirtrim=${PROMPT_DIRTRIM//[^0-9]/}
+ dirtrim=${dirtrim##0}
+ if [ -z "$dirtrim" ]; then
+ echo "$PWD"
+ return $1
+ 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
+ if [ $n -ge $dirtrim ]; then
+ short="/${component:0:1}$short"
+ else
+ short="/$component$short"
+ fi
+ n=$((n+1))
+ done
+ echo "$short/$dirname"
+ return $1
+}
+
function prompt() {
local blurb="Usage: prompt hide|show <what>"