6

In my .zshrc I've set up suffix completion aliases like this so that I can open files more easily:

alias -s -- txt='mate -w'

Which allows me to open text files in my text editor without prepending the editor command.

There is a problem, however, when I am attempting to open a file with a capitalized suffix. ZSH will recognize '.txt' and open it in my text editor but not '.TXT.'

Is there any way to make ZSH suffix recognition case-insensitive so that I can open files like these?

maxhawkins
  • 878
  • 6
  • 18

4 Answers4

5

Let me hazard a guess :)

alias -s -- TXT='mate -w'
alias -s -- Txt='mate -w'
alias -s -- TXt='mate -w'
alias -s -- tXt='mate -w'
alias -s -- txT='mate -w'
alias -s -- tXT='mate -w'
alias -s -- TxT='mate -w'
Inshallah
  • 4,804
  • 28
  • 24
4

This seems to fix it for me:

setopt extendedglob
unsetopt CASE_GLOB

I got the solution from this question

Community
  • 1
  • 1
maxhawkins
  • 878
  • 6
  • 18
0

You can define the suffix aliases once in lower case and redefine them with the extensions programmatically converted to uppercase:

for ext in ${(k)saliases}; alias -s $ext:u=$saliases[$ext]
Guido Cella
  • 1
  • 1
  • 1
0

The following uses the extrapolation of t and T, x and X, and finally t and T. This is really just simplistic combinatorics code, an then assigns that cat.

alias -s {t,T}{x,X}{t,T}=cat

If you run something like echo {t,T}{x,X}{t,T} you can see that I'm just interpolating ttt ttT tTt tTT Ttt TtT TTt TTT in to the alias.

oxagast
  • 397
  • 1
  • 12