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

Re: Problem with fake-files style and cd



On Feb 14,  7:19pm, Mikael Magnusson wrote:
}
} (No, I've modified the _cd completer a bit to only add $cdpath things
} if the first component is already typed out, because when I'm sitting
} in a dir with only one subdir and type cd <tab> i would like that
} directory completed and not the 50 ones in my cdpath. [...])

Well, that was your first mistake. :-)  You should be able to get the
effect you want using styles.

} Of course, my real question should have been if I can make the
} completion listing remove duplicate entries when I have both a real
} directotry and an entry in cdpath that matches, but I guess if you
} have a real dir foo/bar and a cdpath dir foo/baz you want to be able
} to complete to foo/baz too. Maybe it doesn't have to show up as a
} cdpath entry at the foo point though, since the cd builtin won't
} actually go there anyway?

I'm not sure I'm following the last part of that, but what you need to
look at is the documentation for the tag-order zstyle.  I use this:

    zstyle :completion::complete:cd:: tag-order \
	local-directories path-directories

This says to complete only local directories if there are matches for
those, and if there are no local matches then complete only directories
that are found in the cdpath.  Look at the documentation for "Standard
Tags" to find explanation of local-directories and path-directories.

If you want to complete directories in both places but only show the
local ones in listings, you can use the "hidden" style like so:

    zstyle :completion::complete:cd::path-directories hidden yes

(That's not very clear from the documentation for the "hidden" style.)
You probably don't want to use both tag-order and hidden in this case,
but there might be contexts in which you would.

-- 



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