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

Re: Empty directories



On Wed, 01 Oct 2014 14:47:48 +0200
Yuri D'Elia <wavexx@xxxxxxxxxx> wrote:
> In normal file completion, prefix<tab> will accept the entire path (if
> unique) and insert a space after it.
> 
> $ touch pref1_file pref2_file
> $ rm pref1<tab>
> 
> With an empty directory though the path is not accepted even though
> there is nothing more to complete.
> 
> It's a minor difference, I know, but I wanted to know why it's there.

Oh.

When you hit tab the first time, it's just looking for something at the
current path level.  If it's a directory it just adds it.  It has no
idea whether or not it's an empty directory, that's the next level
down.

Then after it's added a / for that directory, you start completing
in that directory and it will now look for whether there's anything
there or not.

To do better, you need a special case in file completion to handle
directory *only* completion.  But it's tricky since in principle there
may be a mixture of directories that are empty and directories that
aren't which would need to be grouped differently.  There are already
way too many cases no one really understands in _path_files, so this
might need an intermediate level for use by cd, rmdir, etc.  This is a
lot of work for something this minor.

pws



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