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

Re: ".."+Tab (and "."+Tab) does not add "/" on MacOS (Sonoma)



 Just noting that you seem to have contradictory statements there?
>> (and "cd ."+Tab) adds "/"
>> (and just "."+Tab) does NOT

Or does the second one mean trying to complete a command name rather
than a chdir target?

Yes, what's (partially) not working is command name or rather command path completion.

On my machine there aren't any files whose name starts with 2 dots. Whenever I type "cd .." and press TAB, a slash is added. If I press TAB a second time, it lists the directories in the parent directory. Further TABs iterate through these directories. Sometimes I want to execute a command that isn't in the PATH and whose relative path starts with "..", then I type ".." and press TAB in the hope that it will auto-complete the slash like it does for "cd .." but that doesn't work. When I press TAB nothing happens, except for a blink, which I guess is to indicate that no possible completion was found.

Interestingly "./.."+TAB works. Same for any other path that ends with "/.." (or "/.").

So I would suggest you look at _complete_help (^Xh) or _complete_debug
(^X?) output to try to find the failure.  ^Xh for me with "." in
command position as above (gmail may wrap lines):
tags in context :completion::complete:-command-::
    commands builtins functions suffix-aliases reserved-words jobs parameters parameters aliases  (_command_names _autocd)
    commands                           (_path_commands _command_names _autocd)
    path-dirs                           (_path_commands _command_names _autocd)
    jobs                           (_jobs _command_names _autocd)
    parameters                           (_parameters _command_names _autocd)
    local-directories                           (_cd _autocd)

Thanks, that starts to explain what's missing. If I do the same, I get the following:

tags in context :completion::complete:-command-::
    commands builtins functions aliases suffix-aliases reserved-words jobs parameters parameters  (_command_names _autocd)
    commands                                                                                      (_path_commands _command_names _autocd)
    jobs                                                                                          (_jobs _command_names _autocd) 

Compared to you, I'm missing the fourth and the last two lines. I guess that the missing " local-directories" explains why ".."+TAB doesn't suggest "../".

Now the question is why do I miss some lines? The only completion related statements that I have in my Zsh configuration are the two following lines in my .zshrc:

autoload -Uz compinit && compinit;
zstyle ':completion:*' special-dirs true;

I'm using Zsh 5.9 on macOS.

Do you have a custom configuration that could explain the additional lines?

Philippe

 
On Thu, Aug 1, 2024 at 9:43 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
On Wed, Jul 31, 2024 at 3:40 AM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> zstyle ':completion:*' special-dirs true;
>
> Thanks to that "cd ..."+Tab (and "cd ."+Tab) adds "/". I also noticed that "<any-path>/.."+Tab (and "<any-path>/."+Tab) adds "/" but for some reason, just ".."+Tab (and just "."+Tab) does NOT add "/". Any idea how that could be fixed?

Just noting that you seem to have contradictory statements there?
>> (and "cd ."+Tab) adds "/"
>> (and just "."+Tab) does NOT

Or does the second one mean trying to complete a command name rather
than a chdir target?

Anyway all of this works for me, e.g.:
schaefer<504> .[TAB]
Completing external command
.turd_MacPorts
Completing builtin command
.
Completing parameter
.zle.esc       .zle.sgr       .shadow.depth  .shadow.stack
Completing local directory
.git/               ../                 ./

(The last two do not appear with special-dirs false)

So I would suggest you look at _complete_help (^Xh) or _complete_debug
(^X?) output to try to find the failure.  ^Xh for me with "." in
command position as above (gmail may wrap lines):
tags in context :completion::complete:-command-::
    commands builtins functions suffix-aliases reserved-words jobs
parameters parameters aliases  (_command_names _autocd)
    commands
                           (_path_commands _command_names _autocd)
    path-dirs
                           (_path_commands _command_names _autocd)
    jobs
                           (_jobs _command_names _autocd)
    parameters
                           (_parameters _command_names _autocd)
    local-directories
                           (_cd _autocd)


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