Why do my autoloaded functions not autoload [the first time]?
The problem is that there are two possible ways of autoloading a function (see the AUTOLOADING FUNCTIONS section of the zsh manual page zshmisc for more detailed information): • The file contains just the body of the function, i.e. there should be no line at the beginning saying function foo { or foo () {, and consequently no matching } at the end. This is the traditional zsh method. The advantage is that the file is called exactly like a script, so can double as both. To define a function xhead () { print -n “\033]2;$*\a”; }, the file would just contain print -n “\033]2;$*\a”. • The file contains the entire definition, and maybe even other code: it is run when the function needs to be loaded, then the function itself is called up. This is the method in ksh. To define the same function xhead, the whole of the usual definition should be in the file. In old versions of zsh, before 3.0, only the first behaviour was allowed, so you had to make sure the file found for autoload just containe