rupa / z

z - jump around
Do What The F*ck You Want To Public License
16.38k stars 1.17k forks source link

Is there a command line option to implement this? #244

Open alphaCTzo7G opened 6 years ago

alphaCTzo7G commented 6 years ago

Common: When multiple directories match all queries, and they all have a common prefix, z will cd to the shortest matching directory, without regard to priority. This has been in effect, if undocumented, for quite some time, but should probably be configurable or reconsidered.

I noticed this option..

frequently I have multiple directories such as tmp under different locations. I typically want to go to the one that is highest on the list.

Is there a way to force this behavior by any command line switch?

rupa commented 6 years ago

try z tmp <whatever> - arguments are processed in order - the way i like to think of it is that it should mirror the way you disambiguate these similar-but-slightly-different paths in your mind.

i bet you think of these dirs to yourself as "tmp foo" or "tmp bar", so the goal is for you to tell z your mental shortcut and get there.

tbf there's a "limit matches to subdirectory" argument that at least one person wanted -maybe that could help your use case, in general z isnt really a thing that you want to "force", if you really absolutely need to get where you're going, cd is the right option for that

rupa commented 6 years ago

you're right though, the "common" thing is hacky and been there forever, but without it, its worse. I have a hard time explaining it, so, it's quite possible i'm having a hard time understanding how it's giving you grief and missing the point of your ask

alphaCTzo7G commented 6 years ago

No problem.. thanks.. I have been doing z tmp <whatever> to get to the specific location, as you mentioned

Say I have the following output from using z at the command line

100 /tmp
213 /media/sf_D/python
316 /home/username/tmp

If I do a z tmp, it is equivalent to cd /tmp, because there are multiple folders which match tmp, and /tmp is the shortest of the 2 matches.

If there is a match, I was thinking that its more intuitive to design z such that we cd to the folder which is ranked highest instead, because the number 316 indicates that its the most used directory.

So is it possible to either modify z or add a switch such that z tmp is equivalent to cd /home/username/tmp instead of cd /tmp in the above example?