Is there some simple way to configure zsh to use the same completer for foo.exe
as for foo
itself for any foo? By default this doesn't seem to happen, and so pressing TAB after git.exe
uses the default file completion instead of Git-specific command completion, as when pressing TAB after git
. I realize I could change this using compdef
specifically for git, but is it possible to do it for all commands at once?
Asked
Active
Viewed 25 times
0

VZ.
- 21,740
- 3
- 39
- 42
-
Since you are on Windows: At least in the Cygwin implementation of zsh, this completion is already builtin. What zsh are you using? Are you sure that you have `foo.exe` in your path? Do a `type -a foo.exe` to verify this. – user1934428 Apr 12 '23 at 06:19
-
I do use zsh from Cygwin and it's not a question of the path, even specifying full path to the command doesn't help -- for me, completing `c:\full\path\to\git.exe` completes file names instead of Git commands. If it is already built-in, at which level is this done, is this a Cygwin or zsh thing? – VZ. Apr 12 '23 at 12:12
-
Path separator is /, not \ . Completion is done in zsh, but I guess that when porting zsh to Cygwin, they have to adapt some pieces for the Windows environment. Try a `type -a cmd`. On my platform, I get as response _cmd is /cygdrive/c/WINDOWS/system32/cmd_. – user1934428 Apr 12 '23 at 12:43
-
Yes, sure, I used backslashes for clarity, but the real path is `/cygdrive/c/whatever/git.exe`. And completion works for `/cygdrive/c/whatever/git`, but not for the one with the `.exe` suffix. – VZ. Apr 12 '23 at 14:27
-
Did you try it with `cmd` as I suggested? In Cygwin (if you look at the executables in you Cygwin /bin directory using Windows explorer), all binaries there have an .exe suffix, but Cygwin is hiding it. When I type `cmd` and then 2 tab characters, I get as list _cmd cmd.exe cmdext.dll cmdial32.dll cmdkey cmdkey.exe cmdl32 cmdl32.exe_, where _cmd_ and _cmd.exe_ denote the identical file. – user1934428 Apr 13 '23 at 06:02
-
I'm sorry, I don't understand what is your point. I'm not asking about completing `foo` itself to `foo.exe`, I'm asking about the completion used for `foo.exe` if it already happens to be present on the command line (due to being copy-pasted there, being the result of an alias expansion, whatever). This has nothing to do with `type -a foo` AFAICS. – VZ. Apr 13 '23 at 13:27
-
I think i don't understand your question then. So you typed on the command line `foo.exe` and then hit the _tab_ key. What expansion would you like to see? – user1934428 Apr 14 '23 at 05:51
-
When I type `git ` (note the space), `TAB` completes Git commands. When I type `git.exe `, it completes file names (default completion). I'd like the latter work like the former but not only for Git (I know how to do this), but for all commands. – VZ. Apr 15 '23 at 12:42
-
Now your requirement becomes clear to me. I found the mentioning of _for **any** foo_ in your question confusing, because `foo` and `foo.exe` are the same, and you basically want to accomplish completion just for _foo_, in a similar way as it is done for _git_. Sadly, I've never specified a new completion command, so I can not help you here. However, in order to find help, I suggest that you also provide the _compdef_ statements you tried (even if they don't work), and that you specify exactly what you hope to see when you press the _tab_ key after `foo`. – user1934428 Apr 15 '23 at 15:11