standard zsh completion for arguments of a zsh function

409 views Asked by At

if I type the following where record is a zsh function

record ls

how do I write a zsh completion for record such that if I write

record ls -

it will use zsh's completion for ls e.g.

-1              -- single column output
-A              -- list all except . and ..
-B              -- print octal escapes for control characters
-C              -- list entries in columns sorted vertically

the record function:

function record () {
    local fp="`date +%F_%H-%M_%s`"
    $@ 2>&1 | tee "${fp}.log"
}

edit time and /usr/bin/time seems to do this e.g

if I do time ls -<tab> it will give me ls's completion, how I do this for my own function?

1

There are 1 answers

1
Francisco On BEST ANSWER

What you want is called _precommand, this should do it for your record command

compdef _precommand record