I'm messing around with the accept-line widget and not getting the results I want. I want to inspect (and log) what is happening to accept-line by finding the underlying zsh function.

My understanding is that zle widgets exist in their own separate namespace with the operation zle -N mapping keys to value in this namespace and the operation zle -A duplicating mappings.

I had quite a detailed search of of the zshzle manual page and did some googling but the best I could come up with is the following that makes use the zle -l operation.

zle -l  | grep '^accept-line ' | grep -Eo '\(.*\)' | tr -d '()'

Is there anything that doesn't depend so directly on the format of the output of zle -l.

1 Answer 1


There is a special array called widgets which holds names of all widgets and functions associated to them, so try

echo $widgets[accept-line]

Be aware however that some widgets are defined internally and all you will get is a word builtin, but judging from your grep command some script sourced in .zshrc overwrote that widget, so you should get meaningful result.

BTW, if you want to list all available widgets and their functions use (kv) flag:

echo ${(kv)widgets}
  • That's what I was after. Some digging shows that although $widgets is not documented in the zle manual it is documented zshmodules (a manual page describing various zsh extension modules)
    – Att Righ
    Apr 12, 2017 at 17:21

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.