Frage

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?

War es hilfreich?

Lösung

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

compdef _precommand record
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top