让 zsh 返回不区分大小写的自动完成匹配,但更喜欢精确匹配 [英] Have zsh return case-insensitive auto-complete matches, but prefer exact matches

查看:44
本文介绍了让 zsh 返回不区分大小写的自动完成匹配,但更喜欢精确匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 zsh 与 oh-my-zsh 的 rc 文件一起使用,我发现有些行为特别烦人.默认情况下,oh-my-zsh 配置为在自动完成时返回不区分大小写的匹配项.这种行为有时很好,但有时真的很糟糕.有没有办法可以将 zsh 配置为仅在没有区分大小写的匹配时使用不区分大小写的匹配?

I am using zsh with oh-my-zsh's rc file and there is some behavior I find particularly annoying. By default, oh-my-zsh is configured to return case-insensitive matches when auto-completing. This behavior is sometimes good, but other times it really sucks. Is there a way I can configure zsh to only use case-insenstive matching when there are no case-sensitive matches?

例如,这种情况将使用区分大小写的匹配:

For instance, this case would use case-sensitive matching:

> ls
LICENSE.txt    lib/
> emacs l <-- should autocomplete to lib/

在这种情况下,会发生不区分大小写的自动完成:

In this case, case-insensitive auto-completion would happen:

> ls
README    lib/
> emacs r <-- should autocomplete to README

谢谢!

推荐答案

只需在 ~/.zshrc 中取消注释以下行:

Just uncomment the following line in ~/.zshrc:

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

它对我有用

这篇关于让 zsh 返回不区分大小写的自动完成匹配,但更喜欢精确匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆