Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

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.

Comments on Case independent tab completion in zsh shell

Parent

Case independent tab completion in zsh shell

+6
−0

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?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

ZSH completion definitions can apply a file name pattern/mask to restrict which files are suggested (5 comments)
Post
+3
−0

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.


  1. compinit in the zsh documentation: https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Use-of-compinit ↩︎

  2. Source in zsh's git repository:https://sourceforge.net/p/zsh/code/ci/master/tree/Completion/Unix/Command/_tex ↩︎

  3. By convention, only completion function files starting with an underscore are autoloaded. (https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Autoloaded-files) ↩︎

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

2 comment threads

Update (1 comment)
Thanks a lot for writing the answer! (2 comments)
Update