I'm looking to write a Bash function that helps me quickly search for and match functions loaded in my current environment. I want it to display any functions that contain the exact text of the first argument I provide. For example, if I call `list_func 'Function: $func'`, I want it to return the entire definition of `list_func()` along with any other matching functions. I have a sample function defined, but I'm open to suggestions on optimizing it or alternative methods to achieve this. Cheers!
2 Answers
Honestly, this seems like over-engineering for what you need.
You can simplify things by sourcing your functions directly from your `.bashrc` file with this:
```
source ~/.bash_functions.d/*
```
Then, to list all functions, just use:
```
declare -F
```
For viewing a specific function, you can do:
```
declare -f waitForHosts
```
Another quick method is this command to list all functions:
```
set | grep '()'
```
You're a towel!