Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: first go at directory info in completion.
- X-seq: zsh-workers 27229
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Subject: Re: PATCH: first go at directory info in completion.
- Date: Sat, 22 Aug 2009 18:55:26 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=eh7vGIEb4TmiDJ6jylYeSIkYh9f2JgbXqysYfqaOarQ=; b=KLzIBbZGqTXZwhWnZyoXuFckEQWirinuauwXBwP1bi87WJqmgXJQ02FJZKiN5DSibx kMrRGzG51HVmFZ2Rgzm8lpq+6piDA0XZ3BUwDr7yG4ZXSc9mu9KKPDJja6uXC8xmf0kF tClWsiTK/YhvxjH6jhMx+6rTN3c0wQouwFDHE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=LQejAKld/9vPxyfiXT3Aw6bW0ZaU2z2eZEABxfn2ImNQLyOvpabbt1YVqeLWHD+1c1 QD7wg6Brn1AGki9t1qtaKvwRLSkPBF5kTrv+z2eArTx3wDNnGyjszrqiM0UyizLEzySP 11ACqrAp4+6DMutCOvrzMUUf+WTvjb1YRyAyw=
- In-reply-to: <20090818145540.GE9893@xxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <19348.1250591605@xxxxxxx> <dbfc82860908180451k176e8bf4y853d335dc240a99c@xxxxxxxxxxxxxx> <200908181200.n7IC0ooX020205@xxxxxxxxxxxxxx> <20090818145540.GE9893@xxxxxxxxxxxxxxxxxxx>
2009/8/18 Vincent Lefevre <vincent@xxxxxxxxxx>:
> On 2009-08-18 13:00:50 +0100, Peter Stephenson wrote:
>> Sometimes you have sets of directories with cryptic names, for example
>> named after bug records, in which you keep information to do with
>> it---anything vaguely database-related gives you this sort of
>> arrangement, in fact. Rather than seeing completion lists like
>>
>> BUG0001 BUG0002 BUG0003 BUG0004
>>
>> you now create a one-line file (say .zshinfo) in each directory
>> describing the directory. Then you can get completion lists looking
>> like
>>
>> BUG0001 # Light switch failed to illuminate room
>> BUG0002 # Light bulb in south east corner of room broken
>> BUG0003 # Wiring behind light switch worn
>> BUG0004 # Loose screw on diffusor in south west corner of room
>>
>> so when changing directory you no longer have to remember a set of
>> 4-digit numbers.
>
> This is nice. However I'd like to see this very configurable. For
> instance, as a Subversion user, I'd rather see such a description
> as a svn property (which would follow the file with "svn mv").
> I hope this would still be efficient enough (or some file like
> .zshinfo could be used as a cache).
I imagine you could make it use (an array of?) function hooks that
you can define yourself, like is done for precmd and friends. In the
meantime I made a quick hack to use xattrs via the z*attr commands I
added a while back.
I also noticed that when in this long list format, all coloring from
file types and etc is lost, is there any way to have both? (without
doing the fabled rewrite).
http://git.mika.l3ib.org/?p=zsh-cvs.git;a=commitdiff;h=97b96f4f1319288b44be00f74781d7e8def76750
(url since the following will probably be corrupted by gmail)
This is on top of pws' patch,
--- a/Completion/Unix/Type/_list_files
+++ b/Completion/Unix/Type/_list_files
@@ -8,7 +8,7 @@
# Sets array listfiles to the display strings and the array
# listopts appropriately to be added to the compadd command line.
-local stat f elt what dir dirfile dirformat
+local stat f elt what dir dirfile dirformat reply dirprop
local -a stylevals
integer ok active
@@ -44,12 +44,17 @@ for elt in $stylevals; do
dirfile=${~elt##dirinfo=}
(( ok )) || (( ok = 2 ))
;;
+
+ (dirprop=*)
+ dirprop=${~elt##dirprop=}
+ (( ok )) || (( ok = 2 ))
+ ;;
esac
done
(( ok )) || return 1
-if [[ -n $dirfile ]]; then
+if [[ -n $dirfile || -n $dirprop ]]; then
zstyle -s ":completion:${curcontext}:" dirinfo-format dirformat ||
dirformat="%f [%i]"
fi
@@ -68,6 +73,19 @@ for f in ${(PQ)1}; do
zformat -f what "$dirformat" d:$dir f:$f i:"$(<$dir$f/$dirfile)"
listfiles+=("$what")
(( active++ ))
+ elif [[ -n $dirprop ]]; then
+ zlistattr $dir$f reply >& /dev/null
+ if [[ ${${(0)reply}[(I)$dirprop]} -gt 0 ]]; then
+ zgetattr $dir$f $dirprop reply >& /dev/null
+ zformat -f what "$dirformat" d:$dir f:$f i:$reply
+ listfiles+=("$what")
+ (( active++ ))
+ elif (( ok != 1 )); then
+ listfiles+=("$f")
+ else
+ # Borrowed from Functions/Example/zls
+ zstat -s -H stat -F "%b %e %H:%M" - "$dir$f" >/dev/null 2>&1
+ fi
elif (( ok != 1 )); then
listfiles+=("$f")
else
(sorry about the copy of the elif+else, i was a bit lazy there :)
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author