+# Example plugin code:
+#
+# __ps1_example_colour='0;33'
+#
+# function __ps1_example() {
+# if [ -n "$__ps1_example" ]; then
+# echo -n "$(__ps1_prefix $1 __ps1_example)"
+# echo -n "example!"
+# fi
+# return $1
+# }
+#
+# The next part of the prompt is the exit status of the last command.
+# This part will be shown only if __ps1_user is set and the exit status is
+# non-zero.
+#
+# The penultimate part of the prompt is the number of background jobs managed
+# by the shell, in square brackets. If all background jobs are running,
+# their number will be shown as [n]. If some are stopped, the number of
+# running (r) and total (t) jobs will be shown as [r/t].
+# This part will be shown only if __ps1_bg is 1. By default it is 0.
+
+# The final part of the prompt is the (full) working directory and $ string.
+# If the shell is running as root the # string's colour can be changed by
+# modifying $ROOT_OK_COLOUR and $ROOT_FAILED_COLOUR.
+#
+# Colouring is performed by the __ps1_col() and __ps1_ret() functions.
+# We redirect stderr to /dev/null when calling these functions to prevent
+# bash complaining about not knowing them when you su to another user,
+# retaining PS1 but not the function definitions.
+#
+# Note that $? is passed as an argument to - and is returned from - all
+# functions. As $? is set following any shell activity it is only guaranteed
+# to represent the return code of the last command at the beginning of __ps1().
+# By passing between subsequent functions we ensure that it is available for
+# __ps1_ret().
+#
+
+# Pick a colour based on the terminal capabilities.
+# OK: dark green.
+# Failed: dark red.
+case $(tput colors) in
+ 256)
+ __ps1_colours=256
+ PROMPT_BACKGROUND_COLOUR="0;48;5;26"
+ PROMPT_OK_COLOUR="1;38;5;34"
+ PROMPT_FAILED_COLOUR="1;38;5;160"
+ ROOT_OK_COLOUR="0"
+ ROOT_FAILED_COLOUR="0"
+ ;;
+
+ 88)
+ __ps1_colours=88
+ PROMPT_BACKGROUND_COLOUR="0;48;5;18"
+ PROMPT_OK_COLOUR="1;38;5;24"
+ PROMPT_FAILED_COLOUR="1;38;5;48"
+ ROOT_OK_COLOUR="0"
+ ROOT_FAILED_COLOUR="0"
+ ;;
+
+ *)
+ __ps1_colours=
+ PROMPT_BACKGROUND_COLOUR="0;44"
+ PROMPT_OK_COLOUR="1;32"
+ PROMPT_FAILED_COLOUR="1;31"
+ ROOT_OK_COLOUR="0"
+ ROOT_FAILED_COLOUR="0"
+ ;;
+esac