From 770e9bbbcb5b830d151e952dac467b48fb3e83b6 Mon Sep 17 00:00:00 2001 From: "martin@piware.de" <> Date: Mon, 6 Apr 2009 14:35:49 -0700 Subject: [PATCH] shellpresent: add variables for colors, support dark background --- shellpresent | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/shellpresent b/shellpresent index a9720d6..b0758f7 100755 --- a/shellpresent +++ b/shellpresent @@ -7,27 +7,51 @@ # (c) 2009 Martin Pitt # 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 " >&2 + echo "Usage: $0 [--dark] " >&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 @@ -35,7 +59,8 @@ while read line; do # 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" -- 2.39.5