Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Case-insensitive completion
- X-seq: zsh-users 6586
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh-users List <zsh-users@xxxxxxxxxx>
- Subject: Re: Case-insensitive completion
- Date: Tue, 16 Sep 2003 17:03:54 +0000
- In-reply-to: <20030915190817.GA582@xxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20030914103053.GA827@xxxxxxxxxxxxxxxxxxxxxxxx> <1030914185817.ZM27558@xxxxxxxxxxxxxxxxxxxxxxx> <20030915190817.GA582@xxxxxxxxxxxxxxxxxxxxxxxx>
On Sep 15, 9:08pm, Jesper Holmberg wrote:
} Subject: Re: Case-insensitive completion
}
} aac.txt aAa.txt Aaa.txt aAb.txt
}
} If I want to complete for "Aaa.txt", it works well, I just put capital "A"
} and hit tab, and since the matching is only one-way, the completer knows
} that I really want a capital A, and gives me Aaa.txt.
}
} If, on the other hand, I wanted aac.txt, hitting "aa" would not really
} help me, since "aAa.txt", "Aaa.txt" and "aAb.txt" would all be proposed
} before my aac.txt. I am thus looking for an easy way to specify that
} *this time* I really want to match on literally "aa".
}
} Perhaps what I want is unachievable, but has anyone solved this in a smart
} way?
Normally the way to do that would be to use different keybindings for
"complete case-insensitively" vs. "complete case-sensitively" and tell
zsh your preference by which of them you invoke.
Start with zstyles something like this:
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*:case-sensitive:*' matcher-list ''
zstyle ':completion:*' completer _expand _complete _ignored
Then, in a file (name doesn't matter much) somewhere in the path where
compinit looks for completion functions, you put:
---- 8< ---- snip ---- 8< ----
#compdef -k complete-word \C-xI
_main_complete _expand _complete:case-sensitive _ignored
---- 8< ---- snip ---- 8< ----
Replace \C-xI (control x shift i) with whatever keybinding you want to
have attached to case-sensitive completion.
You could get a little fancier with the function and avoid hardwiring
the list of completers by copying some of the code from _main_complete
to get the matcher-list context, then modify that list of matchers to
attach :case-sensitive where needed, before calling _main_complete.
Warning, I didn't actually test any of the above.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author