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

Re: Coreutils-like File Completion

On Oct 5,  3:37pm, Leah Neukirchen wrote:
} Subject: Re: Coreutils-like File Completion
} Eric Cook <llua@xxxxxxx> writes:
} > On another note, if you type an ' before pressing tab, zsh will
} > still complete the filename and add the closing ' if an file is
} > selected, the closing ' won't be added if the selected item is an
} > directory (since you may attempt to do further completion).
} This only seems to happen without compinit, anyone know how to revert
} to this behavior and still use compinit?
} (With compinit, ' is removed on TAB and the completion uses \ here...)

Hmm, I don't see your behavior.  I have a directory full of deliberately
strangely-named files just for testing stuff like this.

torch% ls *' '*         
two three  with spaces

a (test):
bar  foo

dir two:
dir3  file two
torch% print 'w<TAB>
torch% print 'with spaces' <C-U>
torch% echo 'a<TAB>
a'\''b      abc         answerfile  a (test)/

Notice how, in the file name that contains a single quote, the listing
has closed the quote after the first "a", then backslashed the embedded
single quote, and then opened the quotes again before "b".  If I cycle
the matches by repeately pressing TAB:

torch% echo 'a<TAB>
torch% echo 'a'\''b<TAB>
torch% echo 'abc'<TAB>
torch% echo 'answerfile'<TAB>
torch% echo 'a (test)/

And so on.  This is all with compinit having run.

You should make sure that you're not confusing completion with expansion,
and for zstyles or setopts that may be making a difference.

There is a bit of a glitch above -- "a'b" is a directory, but the trailing
"/" is not being appended, and completion into that directory doesn't
work; the multiple quotings have confused path completion.  It works if I
allow completion to supply the quoting:

torch% echo a<TAB><TAB>
torch% echo a\'b/

It also works if I start from a double quote so that it's not necessary
to close and reopen the single quotes:

torch% echo "a<TAB><TAB>
torch% echo "a'b/

Figuring out what the user means in order to unwind it, do a path search,
and then put it all back again, is of necessity heuristic, and doesn't
always work.

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