Last active
August 29, 2015 14:22
-
-
Save virullius/e902f92f69bd3d2ff753 to your computer and use it in GitHub Desktop.
interactive shell script with prompt with command history
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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