* which completion function are used for aliases?
@ 2006-03-25 0:08 Andy Spiegl
2006-03-25 18:31 ` Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: Andy Spiegl @ 2006-03-25 0:08 UTC (permalink / raw)
To: zsh-users
When completing the options of an alias, is there a way to make zsh use the
completion function of the corresponding command?
Say, if
condor:~>print ${_comps[program1]}
_program1
condor:~>alias program2
program2=program1 --param1
then I would like zsh to use the completion function _program1 for the
completion of program2? Of course I could manually define
compdef _program1 program2
But is it possible to that automatically for (simple) aliases?
Chau,
Andy.
--
Fotos: francisco.spiegl.de o _ _ _
Infos: peru.spiegl.de __o /\_ _ \\o (_)\__/o (_) -o)
Andy, Heidi, Francisco _`\<,_ _>(_) (_)/<_ \_| \ _|/' \/ /\\
heidi.und.andy@spiegl.de (_)/ (_) (_) (_) (_) (_)' _\o_ _\_v
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Ever wonder about those people who spend $2.00 a piece on those little
bottles of Evian water? Try spelling Evian backwards: NAIVE
(George Carlin, US comedian)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: which completion function are used for aliases?
2006-03-25 0:08 which completion function are used for aliases? Andy Spiegl
@ 2006-03-25 18:31 ` Bart Schaefer
2006-03-26 19:20 ` Andy Spiegl
0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2006-03-25 18:31 UTC (permalink / raw)
To: zsh-users
On Mar 25, 1:08am, Andy Spiegl wrote:
}
} When completing the options of an alias, is there a way to make zsh
} use the completion function of the corresponding command?
It should just happen. What's your setting of the "complete_aliases"
setopt? Try "unsetopt complete_aliases". The name of the option is
somewhat ambiguous -- it means "complete aliases as separate commands
and not as the command for which they are another name."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: which completion function are used for aliases?
2006-03-25 18:31 ` Bart Schaefer
@ 2006-03-26 19:20 ` Andy Spiegl
2006-03-26 20:23 ` Peter Stephenson
0 siblings, 1 reply; 5+ messages in thread
From: Andy Spiegl @ 2006-03-26 19:20 UTC (permalink / raw)
To: zsh-users
Hi Bart,
> Try "unsetopt complete_aliases".
Aaah, interesting! I guess I added this option a long time ago
and had forgotten about it, but the name of the option really is
a bit confusing. :-)
Now, is it also possible to make zsh "know" the options of the alias,
so that I don't have to hardcode the aliases in my completion function?
But how can I get the details of the defined aliases???
Right now, my completion function uses this code:
---------------
local dir=${words[(r)--dir=*]##--dir=}
if [[ -z $dir ]]; then
integer dirind=${words[(i)--dir]}
if (( dirind )); then
dir=$words[dirind+1]
fi
fi
# Default directories (depending on which alias is used)
if [[ -z $dir ]]; then
if [[ $words[1] = gigaset2 ]]; then
dir="/home/spiegl/movies/gigaset/PVR/"
elif [[ $words[1] = gigaset3 ]]; then
dir="/data2/movies/gigaset/PVR/"
elif [[ $words[1] = gigaset-ext ]]; then
dir="/extern-dos/Video/"
else
dir="/data/movies/gigaset/PVR/"
fi
fi
--------------
Thx,
Andy.
PS:
gigaset2='gigaset --dir /home/spiegl/movies/gigaset/PVR'
gigaset3='gigaset --dir /data2/movies/gigaset/PVR'
gigaset-ext='gigaset --dir /extern-dos/Video'
--
New Windows XP error message:
"File not found. Should I fake it? (Y/N)"
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: which completion function are used for aliases?
2006-03-26 19:20 ` Andy Spiegl
@ 2006-03-26 20:23 ` Peter Stephenson
2006-03-27 9:30 ` Andy Spiegl
0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2006-03-26 20:23 UTC (permalink / raw)
To: zsh-users
Andy Spiegl wrote:
> Now, is it also possible to make zsh "know" the options of the alias,
> so that I don't have to hardcode the aliases in my completion function?
>
> But how can I get the details of the defined aliases???
>
> # Default directories (depending on which alias is used)
> if [[ -z $dir ]]; then
> if [[ $words[1] = gigaset2 ]]; then
> dir="/home/spiegl/movies/gigaset/PVR/"
> elif [[ $words[1] = gigaset3 ]]; then
> dir="/data2/movies/gigaset/PVR/"
> elif [[ $words[1] = gigaset-ext ]]; then
> dir="/extern-dos/Video/"
> else
> dir="/data/movies/gigaset/PVR/"
> fi
> fi
>
> PS:
> gigaset2='gigaset --dir /home/spiegl/movies/gigaset/PVR'
> gigaset3='gigaset --dir /data2/movies/gigaset/PVR'
> gigaset-ext='gigaset --dir /extern-dos/Video'
if [[ $aliases[$words[1]] = *" --dir "* ]]; then
dir=${aliases[$words[1]]##*--dir }
fi
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page still at http://www.pwstephenson.fsnet.co.uk/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: which completion function are used for aliases?
2006-03-26 20:23 ` Peter Stephenson
@ 2006-03-27 9:30 ` Andy Spiegl
0 siblings, 0 replies; 5+ messages in thread
From: Andy Spiegl @ 2006-03-27 9:30 UTC (permalink / raw)
To: zsh-users
> if [[ $aliases[$words[1]] = *" --dir "* ]]; then
> dir=${aliases[$words[1]]##*--dir }
> fi
This only works if there is no other option after "--dir /foo/bla".
I'm doing it like this now, but it sub-optimal I'm afraid :-)
------------
if [[ -z $dir ]]; then
# try to read directory from the alias
# e.g. alias gigaset2='gigaset --dir /movies/gigaset/PVR --nowarnings'
if [[ -n $aliases[$words[1]] ]]; then
aliasstring=aliases[$words[1]]
aliaswords=${(z)aliasstring}
local dir=${aliaswords[(r)--dir=*]##--dir=}
if [[ -z $dir ]]; then
integer dirind=${aliaswords[(i)--dir]}
if (( dirind )); then
dir=$aliaswords[dirind+1]
fi
fi
else
# default directory
dir="/data/movies/gigaset/PVR/"
fi
fi
------------
Especially this should be easier, right?
aliasstring=aliases[$words[1]]
aliaswords=${(z)aliasstring}
Thanks,
Andy.
--
Plug-and-Play is really nice, unfortunately it only works 50% of the time.
To be specific the "Plug" almost always works. --unknown source
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-03-27 9:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-25 0:08 which completion function are used for aliases? Andy Spiegl
2006-03-25 18:31 ` Bart Schaefer
2006-03-26 19:20 ` Andy Spiegl
2006-03-26 20:23 ` Peter Stephenson
2006-03-27 9:30 ` Andy Spiegl
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).