-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support smart case #209
Comments
current behaviour is to attempt case sensitive match, if not found, we try case insensitive. i have considered the approach of case-sensitive-if-there's-an-upper-case-letter. I think the code would be cleaner. haven't done it cause current behaviour seems to work pretty well ... |
I have the habit of rarely having upper case in queries. Tend to also not remember case of directories. This throws me in the wrong directory from time to time. I also have a local script where I pipe the output of For the normal usage of |
I also first though smart-case would make the user experience better. But: Consider these directories with their respective "frecencies":
This would be the result of different queries with the two approaches:
In the case of two directories with names with just different cases, the smart-case matching would "hide" the all-lowercase one if it has a lower raking than a mixed-case sibling. |
Agree for the normal use case. I was mainly looking for a way to get case insensitive matches included in the output of |
Maybe @rupa, thoughts? |
This is such a good idea |
@ericbn I think it's rare to have two directories of same name but different case as siblings. Just provide a switch to force case-sensitivity, I'm certain that smart case matching would be the best default. |
and add parameters to force case insensitive (`-i`) or case sensitive (`-s`) matching. There are minor changes from smart-case to the original "prefer case sensitive" implementation. Considering these directories with their respective 'frecencies': 3 /tmp/foo/bar 5 /tmp/foo/Baz 8 /tmp/Baz 13 /tmp/bar 21 /tmp These would be the results of different queries with the two approaches, considering a filesystem that allows directories with same names and different cases: | query | smart-case | prefer case sensitive | |-------|--------------|-----------------------| | tm | /tmp | /tmp | | Tm | (nothing) | /tmp | | ba | /tmp/bar | /tmp/bar | | Ba | /tmp/Baz | /tmp/Baz | | fo ba | /tmp/foo/Baz | /tmp/foo/bar | | fo Ba | /tmp/foo/Baz | /tmp/foo/Baz | Fixes rupa#209
Created PR #221 changing the default matching strategy to smart case, and adding two new parameters to force case insensitive ( |
and add parameters to force case insensitive (`-i`) or case sensitive (`-s`) matching. Also rename `t` variable in main awk script to `now`, as used in the `--add` awk script, use constant regular expression instead of string, and add double quotes to shell script variables. There are minor changes from smart-case to the original "prefer case sensitive" implementation. Considering these directories with their respective 'frecencies': 3 /tmp/foo/bar 5 /tmp/foo/Baz 8 /tmp/Baz 13 /tmp/bar 21 /tmp These would be the results of different queries with the two approaches, considering a filesystem that allows directories with same names and different cases: | query | smart-case | prefer case sensitive | |-------|--------------|-----------------------| | tm | /tmp | /tmp | | Tm | (nothing) | /tmp | | ba | /tmp/bar | /tmp/bar | | Ba | /tmp/Baz | /tmp/Baz | | fo ba | /tmp/foo/Baz | /tmp/foo/bar | | fo Ba | /tmp/foo/Baz | /tmp/foo/Baz | Fixes rupa#209
and add parameters to force case insensitive (`-i`) or case sensitive (`-s`) matching. Also rename `t` variable in main awk script to `now`, as used in the `--add` awk script, use constant regular expression instead of string, and add double quotes to shell script variables. There are minor changes from smart-case to the original "prefer case sensitive" implementation. Considering these directories with their respective 'frecencies': 3 /tmp/foo/bar 5 /tmp/foo/Baz 8 /tmp/Baz 13 /tmp/bar 21 /tmp These would be the results of different queries with the two approaches, considering a filesystem that allows directories with same names and different cases: | query | smart-case | prefer case sensitive | |-------|--------------|-----------------------| | tm | /tmp | /tmp | | Tm | (nothing) | /tmp | | ba | /tmp/bar | /tmp/bar | | Ba | /tmp/Baz | /tmp/Baz | | fo ba | /tmp/foo/Baz | /tmp/foo/bar | | fo Ba | /tmp/foo/Baz | /tmp/foo/Baz | Fixes rupa#209
Hi,
Would it be good idea to support "smart case"? I.e. do case insensitive matching if the query is all lowercase, and do the current case sensitive matching only if the query contains upper-case? This is similar to what e.g.
vim
andfzf
does by default.It could be enabled with e.g.
_Z_SMART_CASE
if there are people who don't like it.I'll submit a PR if this sounds acceptable.
The text was updated successfully, but these errors were encountered: