Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: which completion function are used for aliases?
- X-seq: zsh-users 10093
- From: Andy Spiegl <zsh.Andy@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: which completion function are used for aliases?
- Date: Mon, 27 Mar 2006 11:30:19 +0200
- In-reply-to: <200603262023.k2QKNlaG006386@xxxxxxxxxxxxxxxxx>
- Kinfo: virscan ok
- Kinfo: !spam auth
- Kreccount: 1
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <zsh.Andy@xxxxxxxxx> <20060326192054.GA27247@xxxxxxxxx> <200603262023.k2QKNlaG006386@xxxxxxxxxxxxxxxxx>
> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author