To me it appears that
it completes over all applications that exist on the computer — for instance in zsh I get
is not true. There does not seem to be any awareness for the open
command in bash or zsh. So pressing ⇥ simply uses the fallback and completes over all the files in your current working directory.
If you want bash to be aware of expected arguments to come after the -a
switch of the open
command, you will need to write a bash completion pattern for that.
To do so, you would need to familiarize yourself with the complete
shell builtin
$ help complete
complete: complete [-abcdefgjksuv] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]
For each NAME, specify how arguments are to be completed.
If the -p option is supplied, or if no options are supplied, existing
completion specifications are printed in a way that allows them to be
reused as input. The -r option removes a completion specification for
each NAME, or, if no NAMEs are supplied, all completion specifications.
OS X Lion simply points the user to a dialog showing the /Applications
folder. To gain the list of Apps in there, you can simply use
basename -a -s.app /Applications/*.app
So a very rudimentary completion for open
that does not check the -a
switch nor handles spaces correctly would look like this
_openComp()
{
local WLIST cur
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
WLIST=`basename -a -s.app /Applications/*.app`
COMPREPLY=( $(compgen -W "${WLIST}" -- ${cur}) )
return 0
}
complete -F _openComp open
This applies to bash, i'm not familar with zsh's completion behaviour.
Well you could think about using
lsregister
to read out the various application claims. I don´t have an idea on how to parse the lsregister dump beautifully, but as a start, trylsregister -dump | grep -B 40 "\.avi"
and try to incorporate that in a script. – Asmus – 2011-07-29T14:25:03.043