I need a way to list the names (without the body/content/value) of aliases, functions, variables, arrays in zsh. Optimally it should behave like compgen
:
compgen -a # will list all the aliases you could run.
compgen -A function # will list all the functions you could run.
compgen -A variable # will list all the variables defined.
Background
I need this to develop env_parallel.zsh: https://www.gnu.org/software/parallel/env_parallel.html
Best Answer
Aliases and functions are contained in
aliases
andfunctions
, and one merely needs to print the keys of such. "Variables and arrays" is trickier;parameters
may suffice?(You may also need
builtins
,commands
, and perhaps other things listed fromprint -l ${(k)
and then mashing tab, assuming completion is enabled.)