Skip to content

How can I modify rg (ripgrep) to perform case sensitive search only when the given PATTERN has any uppercase char? #1594

Answered by BurntSushi
tifDev asked this question in General
Discussion options

You must be logged in to vote

You don't need to implement this yourself. ripgrep already has a flag for this: -s/--smart-case:

Searches case insensitively if the pattern is all lowercase.
Search case sensitively otherwise.

This overrides the -s/--case-sensitive and -i/--ignore-case flags.

If you want this enabled by default, then you can either use a function (like you were trying), an alias (i.e., alias rg="rg -S") or create a configuration file and put it there.

Also, in the future, don't just say something "didn't work as expected." Please be sure to provide an example input along with its output and the output you expected. Otherwise, people have to guess what it is that you meant by "expected."

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by BurntSushi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1594 on May 24, 2020 16:25.