6

Is there a command to get builtin commands on zsh? For example, it is possible to get all builtin commands with the compgen -b command in the bash shell.

7

See info zsh builtins:

builtins
This associative array gives information about the builtin commands currently enabled. The keys are the names of the builtin commands and the values are either 'undefined' for builtin commands that will automatically be loaded from a module if invoked or 'defined' for builtin commands that are already loaded.

But note that new builtins are made available when you load more modules with zmodload.

To print the list (the keys of that associative array) raw and ordered on 1 Column:

print -roC1 ${(k)builtins}

Or you can print the key and values on two columns to see which ones are already loaded and which ones would be automatically loaded upon first invocation:

print -raC2 ${(kv)builtins} | sort

To list all commands and reserved words along with their type, see also:

whence -wm '*'
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.