Log: Difference between revisions

From genomewiki
Jump to navigationJump to search
No edit summary
 
No edit summary
Line 7: Line 7:


Then save the following file under the name '''logmenu''' somewhere:
Then save the following file under the name '''logmenu''' somewhere:
 
<pre>
# this scripts needs alias logmenu=source ~/usr/bin/scripts/logmenu  
# this scripts needs alias logmenu=source ~/usr/bin/scripts/logmenu  
# in your bashrc otherwise the cmds will not find the way into your history
# in your bashrc otherwise the cmds will not find the way into your history
Line 27: Line 27:


rm -f /tmp/line /tmp/menuresult /tmp/menu
rm -f /tmp/line /tmp/menuresult /tmp/menu
</pre>
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.

Revision as of 22:55, 9 September 2006

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 

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 get your rocket science result to be able to track down those nasty mistakes 6 months later.

Then save the following file under the name logmenu somewhere:

# 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.