LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Blogs > linux-related notes
User Name
Password

Notices


Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Rate this Entry

Semi-auto-generated, nicely formatted, apropos-like list of your custom bash functions

Posted 10-01-2015 at 12:35 AM by the dsc

Code:
bold=$(tput bold)
normal=$(tput sgr0)

lsfunctions ()
{
tail -n+10 /path/to/custom-bash-functions | grep "()" | sort | sed 's|(.*#||'  | sed "s|^|${bold}|;s|\ |${normal}\ |"
}
↑ Change the number "10" to whichever line you want to start grepping the functions

"lsfunctions" would be like "apropos /usr/bin/*", or whatever really works, but restricted to your custom bash functions, given that they're documented on the line with the "()", like:

Code:
c () # - command line calculator, bc
{ 
echo "$*" | sed 's|^+||;s|x|*|g' | bc -l 
}
Then lsfunctions will show, among whatever else:
Quote:
c - command line calculator, bc
With bold text for "c", or whatever precedes the "()", the function itself.

(And that's what I meant by "auto-generated", just that it greps from the extant documentation and makes the first word bold, instead of one having to create a separate list in a "more" manual manner)

With some tweaking it could grep keywords, like apropos does.
Posted in Uncategorized
Views 1325 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 11:07 PM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration