Visit Jeremy's Blog.
Go Back > Blogs > linux-related notes
User Name


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

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:

c () # - command line calculator, bc
echo "$*" | sed 's|^+||;s|x|*|g' | bc -l 
Then lsfunctions will show, among whatever else:
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 1467 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 05:40 PM.

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