Skip to content

Instantly share code, notes, and snippets.

@milanaleksic
Created May 12, 2017 08:45
Show Gist options
  • Save milanaleksic/2e4cf8d31d68849cb7b774637c1d24ff to your computer and use it in GitHub Desktop.
Save milanaleksic/2e4cf8d31d68849cb7b774637c1d24ff to your computer and use it in GitHub Desktop.
List all known functions
# as long as your functions are located in files mentioned in the "in" clause of the for below
# and as long as functions are following the same pattern of "function_name() {" with a single comment above,
# the function below will list them all in a nice way
# lists all known functions
functions() {
for f in ~/.dockerfunc ~/.functions ~/bash/.extra_*
do
awk '/[^\W].*\(\)\W*\{$/{if (a && a !~ /[^\W].*\(\)\W*\{$/) \
print "\033[1;32m" sprintf("%-30s", substr($0,1,index($0,"(")-1)) "\033[0m\033[1;34m" substr(a,3) "\033[0m (" FILENAME LINE ")" \
} {a=$0}' $f
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment