# (c) 2009 Martin Pitt <martin@piware.de>
# License: Public Domain
+NORMAL=""
+BOLD=";1"
+STATE=$NORMAL
+
+OFF=0
+RED=31$STATE
+GREEN=32$STATE
+YELLOW=33$STATE
+BLUE=34$STATE
+MAGENTA=35$STATE
+CYAN=36$STATE
+
+# Presentation colors
+COMMENT=$GREEN
+PROMPT=$RED
+CMD=$BLUE
+OUTPUT=$OFF
+
+if [ "x$1" = 'x--dark' ]; then
+ shift || true
+ STATE=$BOLD
+ CMD=$YELLOW
+fi
+
[ -e "$1" ] || {
- echo "Usage: $0 <shell script>" >&2
+ echo "Usage: $0 [--dark] <shell script>" >&2
exit 1
}
clear
-echo -en "\e[31m\$\e[30m "
+echo -en "\e[${PROMPT}m\$\e[${CMD}m "
while read line; do
# paragraph clears screen
if [ -z "$line" ]; then
clear
- echo -en "\e[31m\$\e[30m "
+ echo -en "\e[${PROMPT}m\$\e[${CMD}m "
continue
fi
# comment
if [ "${line:0:1}" = "#" ]; then
if [ -n "${line:1}" ]; then
- echo -e "\r\e[32m$line\e[30m"
- echo -en "\e[31m\$\e[30m "
+ echo -e "\r\e[${COMMENT}m$line\e[${CMD}m"
+ echo -en "\e[${PROMPT}m\$\e[${CMD}m "
fi
continue
fi
# execute command
echo -n "$line"
read < /dev/tty
+ echo -ne "\e[${OUTPUT}m"
eval "$line"
- echo -en "\n\e[31m\$\e[30m "
+ echo -en "\n\e[${PROMPT}m\$\e[${CMD}m "
read -s < /dev/tty
done < "$1"