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

Post

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 moderator attention?
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)
ZSH completion definitions can apply a file name pattern/mask to restrict which files are suggested
elgonzo‭ wrote about 2 years ago · edited about 2 years ago

Is there any way to make the tab completion independent of capitalisation while still getting suggested all files?

zsh should come with completion definitions for a number of popular programs, among them latex. autoload -Uz compinit && compinit is basically just a way to load these completion definitions (or so the internet tells me).

Completion definitions have the ability to apply a file name pattern/mask to restrict suggested files to file types actually supported by the program.

The file name pattern in the latex completion def. (https://sourceforge.net/p/zsh/code/ci/master/tree/Completion/Unix/Command/_tex) unfortunately does not include the dtx file extension: *.(tex|TEX|texinfo|texi)(-.).

If you always want to have all files being suggested, i would perhaps suggest to not do autoload -Uz compinit && compinit. Although there is probably a reason why you want to load the completion def's , so you could instead perhaps edit (or remove) the latex completion def. file.

elgonzo‭ wrote about 2 years ago · edited about 2 years ago

P.S.: I have no deeper insight into zsh, nor am i an experienced zsh user. My comment is entirely based on looking at the latex completion definition file in zsh's git repository -- so the confidence level of my comment is at best only average. I don't really know in which folder you would find that completion definition file, nor do i know what the proper way is for modifying/removing/deactivating one/some of zsh's standard completion definitions (i am concerned about possible future zsh updates possibly undoing the changes you made to the completion definition file, or similar situations...)

samcarter‭ wrote about 2 years ago · edited about 2 years ago

elgonzo‭ Thanks a lot for your investigation! This at least explains why the completion behaves in the way it does.

If you always want to have all files being suggested, i would perhaps suggest to not do autoload -Uz compinit && compinit.

The problem is that up to now, that's the only way I have found to get case independent tab completion. Without it, I can't simply tab complete cd des to cd Desktop etc. So I looks as if I have to find out where these files are stored ...

samcarter‭ wrote about 2 years ago · edited about 2 years ago

ohh, it looks like I can simply remove the problematic modules from .zcompdump

If I remove the offending entries about latex from the function

_comps=(
...
'latex' '_tex'
...
)

so that the _tex pattern, you showed in your first comment, is no longer applied to the program latex, I get all my files suggested.

samcarter‭ wrote about 2 years ago

elgonzo‭ Might I be able to persuade you to convert your first comment into an answer? It nicely explains what is happening!