Awasihba’s Log

December 18, 2008

My own bashrc quickhelp

Filed under: programming — Tags: — abhisawa @ 3:58 pm

Many times I write so many functions in my bashrc for quick administration task; but after a while I forget about them and over long run I stop using them because I hardly remember that I did write something like that. Here is function in bashrc which gives you quick overview of all the functions with help of comments.

$HOME/myfunctions

function myhelp {
#This prints help over here
FILE="$HOME/myfunctions"
grep -A 1 ^function $FILE | sed -e '  /^--/d ; /^function/ { s/^function//g; s/{//g;   N;   s/n#(.*)/ - 1/; } '
}

function py {
#Ping yahoo.com
  ping www.yahoo.com
}

function debugAE {
#Start debugging apple events on console
        if [ "$1" == "on" ]
        then
                export AEDebugSends=1
                export AEDebugReceives=1
        else
                export AEDebugSends=0
                export AEDebugReceives=0
        fi
}

In above code , you can modify FILE variable in myhelp() to specify your function file ( over here it is $HOME/myfunctions ). Source the same function file in ~/.bashrc or ~/.profile .

For quick help you type myhelp on prompt , you should get output as follows.



Output

myhelp – This prints help over here
py – Ping yahoo.com
debugAE – Start debugging apple events on console

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.