jethrokuan / z

Pure-fish z directory jumping
MIT License
1.26k stars 44 forks source link

Feature request - add a directory without cding #84

Open mcky opened 4 years ago

mcky commented 4 years ago

I use z -e a lot for in scripts to go to directories I rarely cd to, so some folders which are in reality the most used, stay lower down the rankings.

I'd like these directories to be updated in the Z_DATA file, possibly manually through something like z -a $dir. I'd manually call __z_add in the scripts but that relies on the $pwd.

Happy to raise a PR if you think this is worth adding to the core, otherwise I can add it to my own config

jethrokuan commented 4 years ago

Never thought z would ever be used in a script, that seems somewhat dangerous/non-deterministic.

I suppose __z_add can optionally take a directories as arguments, and use pwd otherwise, if that makes sense.

mcky commented 4 years ago

Sorry script was probably the wrong word, it's fish functions for sublime/vscode/cat'ting files etc, with z's nice autocompletion

 function subz --wraps z
     subl (z -e $argv[1])
 end

I occasionally run into

> catz foo
[bat error]: ''foo' did not match any results': No such file or directory (os error 2)

Which I should write a failsafe for..

jethrokuan commented 4 years ago

I see. I'm open to a PR adding:

  1. Optional arguments to __z_add that when existent, gets added to the index
  2. A flag -u or -a in z as you suggested, which when set in conjunction with -e, calls _z_add with the result before returning

The reason in conjunction is important is because the directory would otherwise be added twice, once manually, and once by the change in directory. If you don't mind the wait I could do it, but would take me a while.