$ quickscript () { filename="$1"; history | cut -c 8- | sed -e '/^###/{h;d};H;$!d;x' | sed '$d' > ${filename:?No filename given} }In order to write bash-scripts, I often do the task manually to see how it works.
I type ### at the start of my session and fetch my commands from history later.
The function fetches the commands from the last occurrence of '###', excluding the function call. You could prefix this with a here-document to have a proper script-header.
Delete some lines, add a few variables and a loop, and you're ready to go.
This function could probably be much shorter...
by David Winterbottom (codeinthehole.com)
from All commands http://ift.tt/1krM0L3
No comments:
Post a Comment