Skip to content
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

Prepopulate DB with static list #143

Open
pcomans opened this issue Nov 11, 2014 · 6 comments
Open

Prepopulate DB with static list #143

pcomans opened this issue Nov 11, 2014 · 6 comments

Comments

@pcomans
Copy link

pcomans commented Nov 11, 2014

I have a static list of customer files which I would like to initialize the database with. These entries should be able to age but should never be dropped. Is this possible in z?

@Rowno
Copy link

Rowno commented Nov 12, 2014

I would find this useful too. My case is I often work from a VM shared file system which doesn't exist when the VM is turned off, causing z to drop the paths.

@dbkaplun
Copy link

dbkaplun commented Jan 8, 2015

👍

@rupa
Copy link
Owner

rupa commented Jan 8, 2015

This seems like a couple issues that are related.

I want to avoid adding "prepopulation" code to z if I can - I swore there was an old issue where we described a couple ways of programatically driving z to get things populated - I can't find it, but I'm hoping something like that might work for the "static list of customer files" scenario.

As far as not dropping paths for e.g. network drives, I've pushed a branch no_prunes that respects the $_Z_NO_PRUNE variable. When that's set, entries will age as usual, and be dropped for disuse, but will not be dropped if the directory doesn't exist.

Please try it out, if it works well, I'll merge it to master.

My hope is maybe having this going will make it less important to prepopulate things, since network shares would behave as expected.

@haakenlid
Copy link

the .z database is just a text file.You could write a simple script using bash/python/perl that adds your default folders if they are missing and source that script in .bashrc

@iandunn
Copy link

iandunn commented May 8, 2020

I'd also love to see a solution to this problem. Even after a few weeks of usage, I'm sure I'll still regularly run into situations where I have to manually cd to a folder with a long path. Manually adding them all would be very tedious.

Multiply that by all the local and remote systems I regularly work with. And that work could also get wiped out because of #198, or just moving to a new device.

I think @rupa may have been referring to #48 (comment) as a way to prime the datafile:

# add all subdirs of current directory to index, with rank 5
for x in {1..5}; do 
    find "." -type d -exec z --add \'\{\}\' \; 
done

That gives me find: z: No such file or directory errors on OSX, but I haven't dug into why. find should probably -prune commonly unwanted folders, like .git, node_modules, .sass-cache, etc.

@iandunn
Copy link

iandunn commented May 8, 2020

Made some progress; no errors, but nothing gets added to the datafile either.

find "$(pwd)" -type d -exec /usr/local/Cellar/z/1.9/etc/profile.d/z.sh --add \'{}\' \;

  • Use pwd to get absolute paths
  • Use full path to z.sh because find isn't aware of the z function
  • chmod +x z.sh if you haven't already

Still needs to exclude things like .git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants