(Partially) Extracted from (previous draft) of #16 (comment) :
Currently the tab completion algorithm takes a fairly conservative approach to offering completions for file names. While some commands' (cd, ls, file, stat, somewhat surprisingly tar, … ) completions are configured to assume a file may come at an initial (or any post-flag) position and offer suggestions accordingly, others (mkdir, vi - at least with my shell config, …) play it safe and wait to see an explicit -- before any file completions are offered.
This is the case even when Tab is proceeded by ./, ../ or /
I suggest there are at least 3 heuristic approaches that might be reasonable:
Assuming paths should follow on:
^\.{0,2}/ or indeed ^[./] – this would catch all explicitly rooted paths (at the cost of ignoring or requiring special handling for the rarely-used DOS-style /? flag; and having some false positives)
^[^-+] except where there is an explicit expectation of sub-commands for e.g. git, or stuff like dd's k=v style, etc. This is likely how many commands currently behave
- the latter but as part of a state machine that gets more eager when/if someone typed (or accepted suggestion(s) for) {
-, -- or +} style flag(s) followed by a space and not then another - or +
The logic of 3 would aim so that:
-
flags/subcommands are always offered on first bare (space-)tab and possibly each subsequent til no suggestion is selected from offered completions
[currently they are not. Generally, for both e.g. ls and mkdir flag completions are offered only after a -Tab, and (for those like mkdir) nothing is offered on bare Tab]
-
once the flag suggestions have been dismissed (and/or space is pressed, as accepting a suggestion with either tab or enter does not currently add a trailing space*) assume a subsequent tab should offer completions from current working directory
*That accepting doesn't add a trailing space is perhaps a bug as it stands, because additional Tab seems to be ignored rather than offering additional flags to add to an ~option clump (as does, for example, /usr/share/zsh/5.8/functions/_ls /usr/share/zsh/5.8/functions/_mkdir ). As such one is gonna have to type Space-Tab even if one does want more flag suggestions (unless there is some way to multi-select?)
If it were the default behavior, however, one would likely still want to suppress for Java/Go-std-lib -key=val and POSIX(?) --key=val style flags
(Partially) Extracted from (previous draft) of #16 (comment) :
Currently the tab completion algorithm takes a fairly conservative approach to offering completions for file names. While some commands' (
cd,ls,file,stat, somewhat surprisinglytar, … ) completions are configured to assume a file may come at an initial (or any post-flag) position and offer suggestions accordingly, others (mkdir,vi- at least with my shell config, …) play it safe and wait to see an explicit--before any file completions are offered.This is the case even when Tab is proceeded by
./,../or/I suggest there are at least 3 heuristic approaches that might be reasonable:
Assuming paths should follow on:
^\.{0,2}/or indeed^[./]– this would catch all explicitly rooted paths (at the cost of ignoring or requiring special handling for the rarely-used DOS-style/?flag; and having some false positives)^[^-+]except where there is an explicit expectation of sub-commands for e.g.git, or stuff likedd'sk=vstyle, etc. This is likely how many commands currently behave-,--or+} style flag(s) followed by a space and not then another-or+The logic of 3 would aim so that:
flags/subcommands are always offered on first bare (space-)tab and possibly each subsequent til no suggestion is selected from offered completions
[currently they are not. Generally, for both e.g.
lsandmkdirflag completions are offered only after a-Tab, and (for those likemkdir) nothing is offered on bareTab]once the flag suggestions have been dismissed (and/or space is pressed, as accepting a suggestion with either tab or enter does not currently add a trailing space*) assume a subsequent tab should offer completions from current working directory
*That accepting doesn't add a trailing space is perhaps a bug as it stands, because additional Tab seems to be ignored rather than offering additional flags to add to an ~option clump (as does, for example,
/usr/share/zsh/5.8/functions/_ls/usr/share/zsh/5.8/functions/_mkdir). As such one is gonna have to type Space-Tab even if one does want more flag suggestions (unless there is some way to multi-select?)If it were the default behavior, however, one would likely still want to suppress for Java/Go-std-lib
-key=valand POSIX(?)--key=valstyle flags