typeset -A __MACROS
macro() {
    cmd=$(tail -n 2 $HISTFILE | head -n 1 | awk -F';' '{print $2}')
    alias $name="eval $(echo $escaped_cmd)"
    kv=($name $escaped_cmd)

macros() {
    for key val in ${(kv)__MACROS}; do
      echo "$key -> $val"

Ever have a really, really long command line and you wish that you could make an alias, but you’re too lazy to copy and paste?

$ cat Makefile | sort | uniq | tac
$ macro x
$ alias x
x='eval cat\ Makefile\ \|\ sort\ \|\ uniq\ \|\ tac'

Big missing feature is the ability to save these to a file.