#!/bin/bash # # Present a list of shell commands by single-stepping and echoing commands. # Note that this only works well for self-contained single lines, no multi-line # loops etc. # # (c) 2009 Martin Pitt # License: Public Domain [ -e "$1" ] || { echo "Usage: $0 " >&2 exit 1 } clear echo -en "\e[31m\$\e[30m " while read line; do # paragraph clears screen if [ -z "$line" ]; then clear echo -en "\e[31m\$\e[30m " 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 " fi continue fi # execute command echo -n "$line" read < /dev/tty eval "$line" echo -en "\n\e[31m\$\e[30m " read -s < /dev/tty done < "$1"