On 2021-02-02 6:21 p.m., Bart Schaefer wrote:
_fn2hist() {
emulate -L zsh
local cmd=$1
shift
if [[ -n $functions[$cmd] ]]
then
print -rS "${$(functions -x 2 $cmd)#$cmd} ${${(qq)@}}"
fi
$cmd "$@"
}
Intended to be used like this:
myfn() { : do whatever myfn does }
alias myfn='_fn2hist myfn'
Cool. Only thing is that when you pop it out of history it contains the
'_fn2hist' as well as the subsequent command. This could obviate all my
" alias g='noglob _g' " stuff. Can the function and its tail be saved to
a variable instead of to history? Mind I'm being lazy I'm sure I can
figure that out easy enough. Seems '(qq)' is our friend there for
keeping things unexpanded.