Skip to content

Instantly share code, notes, and snippets.

@virullius
Last active August 29, 2015 14:22
Show Gist options
  • Save virullius/e902f92f69bd3d2ff753 to your computer and use it in GitHub Desktop.
Save virullius/e902f92f69bd3d2ff753 to your computer and use it in GitHub Desktop.
interactive shell script with prompt with command history
PROMPT="cool-tool>"
function do_one {
echo "one"
}
function do_two {
echo "two"
}
while read -e -p "$PROMPT " line
do
history -s "$line"
case "$line" in
one)
do_one
;;
two)
do_two
;;
quit)
exit 0
;;
*)
echo "unknown command \"$line\""
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment