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

Re: Absolute path tab completion on Windows



On Fri, Nov 8, 2024 at 12:03 AM Ram Rachum <ram@xxxxxxxxxx> wrote:
>
> On Fri, Nov 8, 2024 at 2:18 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>>
>>   ${${(M)${(fL)"$(mount)"}:#[a-z]:*}%%:*}
>>
>> I left out the "sort -u" because (a) the order shouldn't matter
>
> On my system this results in `c c c c g j l m p` so I'll keep the implementation with `sort -u`.

I'm surprised by the multiple c: references, but just add (u) to make
them unique.

    ${(u)${(M)${(fL)"$(mount)"}:#[a-z]:*}%%:*}

>> _normal () {
>>   if [[ $PREFIX != /*/*/* ]] && compset -P
>> "/(${(j:|:)${(M)${(fL)"$(mount)"}:#[a-z]:*}%%:*})/"
>
> This works for /c/ but not for my other drives.

Ah, as I said, tweaking.  Need a couple of "preserve array-ness"
operations because of the outer double-quotes:

  "/(${(j:|:)${(@u)${(@M)${(fL)"$(mount)"}:#[a-z]:*}%%:*}})/"

But you're right, since every drive is just a single letter you can do
it with a character class instead of with alternation.  I couldn't do
that because I was testing with (lib|tmp|usr).

  "/[${(j::)${(@u)${(@M)${(fL)"$(mount)"}:#[a-z]:*}%%:*}}]/"

However, I think even that is overkill -- there isn't anything that
matches the pattern /?/ yet is not a drive letter, is there?  So just

  if [[ $PREFIX != /*/*/* ]] && compset -P /?/

should set $IPREFIX to the drive path.

On Fri, Nov 8, 2024 at 12:06 AM Ram Rachum <ram@xxxxxxxxxx> wrote:
>
> Oh, now I find that it only works when autocompleting the first folder and not any subsequent folders... So it'll complete /c/win to /c/Windows but it won't complete /c/Windows/sys to /c/Windows/System.

Hm, I'd like to see ^X? (completion debugging) output for that,
because it might be related to the attempt to match
case-insensitively.




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