Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: conditionally match part of file name to most recently modified file - take 2



On Jun 18, 11:46pm, Eric Smith wrote:
}
} I would like to have certain commands automatically run this function.
} This I currently do with the following:
} #compdef vim less sed perl ooffice ...

Well, *that* you don't do with the #compdef.  What you do with the
compdef is arrange that a certain completer is run for all of those
functions when you press tab, which is not what you asked for.  Which
do you actually want?

} Then I would like to type
} "ooffice foo"
} 
} And the function would execute:
} ooffice foo

You can define multiple functions at once:

    setopt function_argzero
    function vim less sed perl ooffice ... {
      set -- $1 ${${1:h}:-.}/*${1:t}*(Nom[1]) $1
      [[ -f $1 ]] || shift
      command $0 $1
    }

Tweaks, such as not doing this when there's more than one argument,
are left as an excercise.



Messages sorted by: Reverse Date, Date, Thread, Author