Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I can type

alias

and get a list of defined aliases in zsh

How can I get a list of function names defined in zsh?

When I type "functions", my shell window hangs after displaying lots of functions, always ending at

__rvm_checksum_none () {
    [[ -z "${_checksum_md5:-}" && -z "${_checksum_sha512:-}" ]]
}
__rvm_checksum_read () {

What's super annoying is that this won't quit with ctrl-c (using item2 AND terminal).

iterm2: enter image description here

Picture of terminal having the same issue: enter image description here

share|improve this question
    
Usually the listing is done with the functions builtin. Do you get an output if you undefine the problematic(?) function first: unfunction __rvm_checksum_read? –  mpy Dec 4 '13 at 19:13
    
What if I want to get the functions list (not full declarations)? If I unfunction that method, another __rvm_curl also has issues. –  justingordon Dec 5 '13 at 2:08
    
See my answer. But the behavior you describe sounds strange... so just out of interest: Does the full listing work with another terminal emulator? Can you use the problematic functions successful? –  mpy Dec 5 '13 at 9:09
    
terminal has the same issue as item 2. The answer below is AWESOME. While I'd like to know why the terminal hangs just using the 'functions' command (even when piped to less), does it matter? Any reason this will cause issues? –  justingordon Dec 5 '13 at 20:31
    
I supposed there are some really strange character sequences in these functions which mess up the terminal. To narrow this down you could redirect the output to a file functions > /tmp/foo. If it's a zsh problem this should've issue, too. When it's a terminal problem it shouldn't. If your problem may interfere with everyday's usage -- I could not say, sorry. –  mpy Dec 5 '13 at 23:16

1 Answer 1

up vote 1 down vote accepted

With cheating by looking at the _functions completion function, I'm able to answer your question:

The functions are stored in an associative array functions, so to get only the function names (k flag for keys) in alphabetical order (o flag for ordering) you can use

print -l ${(ok)functions}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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