我需要一种方法来列出 zsh 中别名、函数、变量、数组的名称(不包括正文/内容/值)。最好它应该表现得像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.
Run Code Online (Sandbox Code Playgroud)
背景
我需要这个来开发 env_parallel.zsh:https ://www.gnu.org/software/parallel/env_parallel.html
thr*_*rig 27
别名和函数包含在aliasesand 中functions,只需要打印这样的键即可。“变量和数组”比较棘手;parameters可能就足够了?
print -rl -- ${(k)aliases} ${(k)functions} ${(k)parameters}
Run Code Online (Sandbox Code Playgroud)
(假设启用完成builtins,您可能还需要, commands,以及从print -l ${(k)mashing列出的其他内容tab。)