Welcome to the Power Users community on Codidact!
Power Users is a Q&A site for questions about the usage of computer software and hardware. We are still a small site and would like to grow, so please consider joining our community. We are looking forward to your questions and answers; they are the building blocks of a repository of knowledge we are building together.
Case independent tab completion in zsh shell
I'm using a zsh shell with
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
autoload -Uz compinit && compinit
to allow tab completion regardless of capitalisation, e.g. cd desk
will be completed to cd Desktop
However using autoload -Uz compinit && compinit
has a strange side effect. Let's assume I have a folder with the two files
test.dtx
test.tex
If I start to write latex te
and press tab, it will automatically complete to latex test.tex
instead of suggesting me both files. For other commands, e.g. ls te
, the tab completion will complete to ls test
and suggest both files.
Is there any way to make the tab completion independent of capitalisation while still getting suggested all files?
1 answer
The following users marked this post as Works for me:
User | Comment | Date |
---|---|---|
samcarter | (no comment) | Feb 13, 2022 at 19:22 |
zsh comes with a number of completion function files for popular programs and commands that govern how completions and suggestions are executed in relation to these programs/commands.
autoload -Uz compinit && compinit
is basically just a way to load and initialize these completion functions[1].
One feature of such completion function is the ability to constrain file suggestions for the respective program/command based on file name patterns, so as to not suggest files that the respective program/command won't be able to consume.
Unfortunately, the completion function for latex[2] is missing the dtx file extension in its file name pattern *.(tex|TEX|texinfo|texi)(-.)
, and thus dtx files will not be suggested for latex.
Update: As per this comment, future versions of zsh will include the dtx file extension in the file name pattern for the latex completion function, thus the solutions/workarounds described below shouldn't be necessary anymore with respect to future zsh releases/updates.
As samcarter themselves found out (link to comment), for making zsh suggest all files for latex, it is sufficient to remove the entry for the latex completion function from the ".zcompdump" file. Alternatively, the latex completion function file ("_tex") might be removed from the directory with the completion function files, or renamed to a file name that does not start with an underscore[3]. It has to be seen, though, whether such measures will survive a possible future update of the zsh installation.
-
compinit in the zsh documentation: https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Use-of-compinit ↩︎
-
Source in zsh's git repository:https://sourceforge.net/p/zsh/code/ci/master/tree/Completion/Unix/Command/_tex ↩︎
-
By convention, only completion function files starting with an underscore are autoloaded. (https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Autoloaded-files) ↩︎
1 comment thread