Log: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
This was inspired by a [http://www.kuro5hin.org/story/2005/12/28/223217/93 post on kuro5hin] some time ago, questions from wet-lab collegues ("you don't keep protocols?????"), own negative experiences ("How the heck did I create this damn bed-file three days ago?") and also by the makeDbxxxx files in the source tree. Of course, makefiles are better than shell scripts, but often you're just hacking around and don't want to bother with escaping those $s, tab-characters, etc. (It would be nice to know what kind of scripts the UCSC people use to for their makeDbxxx protocols...) | This was inspired by a [http://www.kuro5hin.org/story/2005/12/28/223217/93 post on kuro5hin] some time ago, questions from wet-lab collegues ("you don't keep protocols?????"), own negative experiences ("How the heck did I create this damn bed-file three days ago?") and also by the makeDbxxxx files in the source tree. Of course, makefiles are better than shell scripts, but often you're just hacking around and don't want to bother with escaping those $s, tab-characters, etc. (It would be nice to know what kind of scripts the UCSC people use to for their makeDbxxx protocols...) (We write our shell commands in the makeDb/*.txt files first, then cut and paste those commands to the command line. If they are incorrect, they are corrected in the *.txt file, then cut and paste again to the command line until they work right. The *.txt file is open in an editor until a sequence of operations is completed. --Hiram) | ||
Add these two lines to your .bashrc: | Add these two lines to your .bashrc: |
Revision as of 17:33, 11 September 2006
This was inspired by a post on kuro5hin some time ago, questions from wet-lab collegues ("you don't keep protocols?????"), own negative experiences ("How the heck did I create this damn bed-file three days ago?") and also by the makeDbxxxx files in the source tree. Of course, makefiles are better than shell scripts, but often you're just hacking around and don't want to bother with escaping those $s, tab-characters, etc. (It would be nice to know what kind of scripts the UCSC people use to for their makeDbxxx protocols...) (We write our shell commands in the makeDb/*.txt files first, then cut and paste those commands to the command line. If they are incorrect, they are corrected in the *.txt file, then cut and paste again to the command line until they work right. The *.txt file is open in an editor until a sequence of operations is completed. --Hiram)
Add these two lines to your .bashrc:
alias logadd='history 2 | head -n 1 | cut -d" " -f4- >> log' alias logmenu=source ~/usr/bin/scripts/logmenu
(Please adjust the path ~/usr/bin/scripts here to the directory where you keep your scripts)
When you type logadd now, the last command you typed will be appended to a file called "log". So its a good habit to use logadd after you have found just the right combination of blat, pslSelect, overlapSelect and faPolyASizes, to be able to track down those nasty mistakes 6 months later.
Then save the following file under the name logmenu in the directory where you keep your scripts:
# this scripts needs alias logmenu=source ~/usr/bin/scripts/logmenu # in your bashrc otherwise the cmds will not find the way into your history #!/bin/bash if [ "$1" == "-h" -o -z $1 ]; then echo logmenu: display the file \"log\" as a menu and let the user choose a command to execute echo uses the program \"dialog\" fi echo -n dialog --menu logfile 24 70 18\ > /tmp/menu cat log | tr -d \' | gawk "{ ORS=\" \"; print NR, \"\'\" \$0 \"\'\" } " >> /tmp/menu . /tmp/menu 2> /tmp/menuresult line=`cat /tmp/menuresult` echo $line head -n $line log | tail -n 1 > /tmp/line history -r /tmp/line . /tmp/line rm -f /tmp/line /tmp/menuresult /tmp/menu
Now, when you type logmenu somewhere, a nice menu will pop up, you can select a command, which will then be run and also put into your history, so you can press the up-arrow-key, modify it, run it again, etc.