Skip to content

Instantly share code, notes, and snippets.

@kamranzafar
Last active December 18, 2015 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamranzafar/5772617 to your computer and use it in GitHub Desktop.
Save kamranzafar/5772617 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Ad-hoc shell script generator
# Kamran (xeus.man@gmail.com)
# Generates script (default=doit) for the executed commands
# After generation, commands can be re-run using the doit script
echo "Ad-hoc shell script genertor started"
SCRIPT_FILE=$1
if [ -z "$1" ]
then
SCRIPT_FILE="doit"
fi
rm -f $SCRIPT_FILE
echo "#!/bin/sh" >> $SCRIPT_FILE
echo >> $SCRIPT_FILE
while read inputline
do
if [ "$inputline" = "exit" ]
then
break
fi
$inputline
echo "$inputline" >> $SCRIPT_FILE
echo >> $SCRIPT_FILE
done
chmod -f +x $SCRIPT_FILE
echo "Done!"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment