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

How do I specify the directory in which zoxide stores its database? #267

Closed
Raytle opened this issue Sep 28, 2021 · 10 comments
Closed

How do I specify the directory in which zoxide stores its database? #267

Raytle opened this issue Sep 28, 2021 · 10 comments

Comments

@Raytle
Copy link

Raytle commented Sep 28, 2021

At https://github.com/ajeetdsouza/zoxide#environment-variables
I don't understand how to use _ZO_DATA_DIR.

I tried...
zoxide _ZO_/home/my_user_name/folder_name
and
zoxide_ZO_/home/my_user_name/folder_name

but neither worked.

Man oh man am I tired of, "Come on everybody use Linux on your desktop! You only need squander your time learning a bunch of arcane terms!!" I steadfastly refused to use MS Windows throughout the 90's and instead used a Mac because I didn't want to learn arcane MS-DOS commands. Around 2000 I switched to MS Windows... and never bothered learning arcane MS-DOS commands. Around 2015 I switched to Linux for my desktop (I had it on a server starting around 2003, but that was setup by a Linux sys admin, not me) and am working assiduously to avoid learning arcane Bash commands.

Do you really want to be marginalized to dwell in a "tech ghetto"? It's ridiculous to expect normal people to learn arcane tech jargon. Oh, you are too busy to spend one minute to explain tech jargon because you can't be bothered to write proper documentation? Great! Enjoy life in your tech ghetto. And be sure to complain vociferously to your fellow ghetto dwellers about foolish normal people who don't learn your arcane tech jargon.

Yeah. I work with engineers. How could you tell? /s. I generally despise and rally against this common sort of pseudo-elitism most engineers seem to be infected with. Sure, many people buy Apple's overpriced computers and phones as status symbols. But many people buy Apple's overpriced computers and phones because Apple does an excellent job of shielding ordinary users from the need to learn arcane tech jargon.

Google's ChromeOS (which, of course, runs on Chromebooks) runs on Linux yet has become extremely popular with normal users. Can you guess why?

@ajeetdsouza
Copy link
Owner

ajeetdsouza commented Sep 28, 2021

Sounds like you had a long day! 😂

The arcane jargon you're looking for is "how to define an environment variable in Bash". The reason I haven't included instructions for this is that it varies between shells (and sometimes even between operating systems). Consider that zoxide supports 8 shells on Linux, macOS, BSD, and Windows at the moment!

What makes it worse is that environment variables can be defined in more than one place, depending on the situation. For Bash on Linux itself, you can define it in ~/.profile, ~/.bash_profile, or ~/.bashrc. On macOS, only ~/.bashrc is included by default. It often just boils down to preference.

Since you're using Bash, here's the easiest way you can do it:

export _ZO_DATA_DIR="~/wherever/you/want"
eval "$(zoxide init bash)"

Feel free to create an issue if you have more doubts. I'm sorry you found the documentation lacking -- while I try to keep it as clear as possible, I do have to make a few assumptions about the user if I want to avoid writing pages and pages of text!

@Raytle
Copy link
Author

Raytle commented Sep 28, 2021

Sounds like you had a long day! joy

No.

Rather, I simply hate dealing with self-centered, ignorant engineers. I habitually attack and pillory their foolish arguments.

The arcane jargon you're looking for is "how to define an environment variable in Bash".

The arcane jargon you failed to shield users from because you'd rather indulge yourself spending countless hours writing code but couldn't be bothered to spend an extra 15 minutes writing proper documentation.

The reason I haven't included instructions for this is that it varies between shells (and sometimes even between operating systems). Consider that zoxide supports 8 shells on Linux, macOS, BSD, and Windows at the moment!

What makes it worse is that environment variables can be defined in more than one place, depending on the situation. For Bash on Linux itself, you can define it in ~/.profile, ~/.bash_profile, or ~/.bashrc. On macOS, only ~/.bashrc is included by default. It often just boils down to preference.

Since you're using Bash, here's the easiest way you can do it:

export _ZO_DATA_DIR="~/wherever/you/want"
eval "$(zoxide init bash)"

Thank you very much for that. I appreciate it.

Now. Do. Not. Be. Lazy. Instead, go add that to the documentation on Github right over here --->

https://github.com/ajeetdsouza/zoxide/#environment-variables

Do it now so that you don't "forget". Engineers "forget on purpose" very frequently.

Feel free to create an issue if you have more doubts. I'm sorry you found the documentation lacking -- while I try to keep it as clear as possible,

I do have to make a few assumptions about the user if I want to avoid writing pages and pages of text!

Look. Ok? If zoxide supports 8 shells on Linux, macOS, BSD, and Windows at the moment then maybe it would take you 15 minutes to put in 8 examples like the one you created for me.

Engineers almost invariably hate writing documentation; therefore, they almost invariably make inane excuses for not writing it. Enjoy life in your tech ghetto: it's a lonely place to dwell.

Want to have a miserable life? Keep thinking about what you want and what makes sense to you while ignoring the needs of others. Then be sure complain vociferously when your boss, wife, children etc. do the same to you. I generally loathe dealing with engineers because they are almost invariably clever hypocrites.

Ideally, technology is supposed to serve people, not vice-versa. Don't spend countless hours writing code and then promote it for public use without spending at least a few hours to properly document it. Ideally you should watch a novice user try to use one of your beloved little creations (that is, one of your programs). If you were to do so I think you'd be shocked at how byzantine and inexplicable many features you create seem to most novice users.

Want a life filled with endless strife and intractable internecine struggles? Do what makes sense to you without considering the needs of others.

Want to have a better more peaceful life? Teach yourself to listen to others and to then to try to see the world through their eyes.

@Raytle
Copy link
Author

Raytle commented Sep 28, 2021

export _ZO_DATA_DIR="~/wherever/you/want"
eval "$(zoxide init bash)"

I just tested the above. It worked great!

I just moved db.zo to where it obviously belongs on Ubuntu/Debian...

~/.config

Now I can remove the line I added a couple of hours ago to backup ~/.local/share/zoxide from my little bash script which creates a tar file for me on a weekly basis and then, which, a hacky little Python script I wrote uploads to Google Drive because I had previously set up my bash script to backup ~/.config.

I am so, so, so, sick and tired of learning technical jargon. I hate writing bash and Python scripts to do tasks which engineers should have already solved.

I wish some engineer would have said to himself, "Oh, I see. You and millions of other people want to automatically backup some of your data from your local drive to Google Drive each week so that if your computer were to go down you wouldn't have to 'reinvent the wheel'? Sure. Here's an application that will do that for you via your GUI so you don't have to give rsync access to your Google Drive."

@ajeetdsouza
Copy link
Owner

I've put up a link in the README for those who don't know how to set environment variables, do check it out.

@Raytle
Copy link
Author

Raytle commented Sep 29, 2021

Why not add something like the following?

screenshot #1

That screenshot comes from my notes.

The examples at https://github.com/ajeetdsouza/zoxide/wiki/HOWTO:-set-environment-variables are bad because they are unnecessarily abstract.

“If you can't explain it to a 5 year old [child], you don't understand it yourself.” Albert Einstein

Apple has made enormous profits by following the KISS principle.

In other words, any fool can make simple things unnecessarily complicated. However, it takes a clever man to make complicated things simple.

@ajeetdsouza
Copy link
Owner

Why not add something like the following?

Because it lacks conciseness. While your notes cover one specific scenario, there are currently 6 variables (and counting) that need to be documented.

As a user, if I had to scroll through 8 per-shell instructions (including the zoxide init part, which has already been covered) for each environment variable on another project's README, I would find it quite annoying. Given that you yourself don't want to do a quick Google search on how to set environment variables, I'm not sure you would have scrolled through that much text either.

Instead, I'm now telling a user "you can configure zoxide using environment variables, here's how you set an environment variable" and then showing them a list of possible environment variables they can set. I think that's a much better middle ground. If you can think of a way to make it easier that doesn't involve repeating myself 8 times, that would be great.

@Raytle
Copy link
Author

Raytle commented Sep 29, 2021

If you can think of a way to make it easier that doesn't involve repeating myself 8 times, that would be great.

To help me answer your implicit question, please answer my explicit question below.

Because I am running Lubuntu 20.04 LTS when I ran apt install zoxide it failed. Therefore, I ran curl -sS https://webinstall.dev/zoxide | bash to install zoxide. If I had been running a distro based on Ubuntu 21.04+ and if I had run apt install zoxide then would a folder have been created in /home/y/.config. In other words, would a folder have been created in here?...

screenshot #2

I am asking because I almost always install software applications using apt install package_name. In such cases the software applications almost invariably automatically create a folder in /home/y/.config.

Therefore, I am wondering if—by using curl -sS https://webinstall.dev/zoxide | bash to install zoxide—I inadvertently created the problem I experienced which was basically, "Ummm. Hmmm. Why are my preferences for zoxide in ~/.local/share/zoxide instead of ~/.config/zoxide?" In other words, for example, (I am merely guessing) did you you chose to have zoxide create ~/.local/share/zoxide because (I am merely guessing) that is the default location where applications store preferences in (I am merely guessing) Arch Linux?

See, I almost never need to wonder, "Gee, where did the new application I just installed choose to save its data (such as preferences)." Instead, I simply go to /home/y/.config, find the folder the new application I just installed created automatically in /home/y/.config, and then say to myself, "Yep. This is where the new application I just installed saves its data. My Python script that triggers a Bash script will back that up for me to Google Drive."

@ajeetdsouza
Copy link
Owner

ajeetdsouza commented Sep 29, 2021

zoxide picks ~/.local/share/zoxide to store its database on all Linux systems. The reason it doesn't go in ~/.config is because it's a database, not a configuration file. Configuration files are meant to be user-editable -- they're often entirely handwritten. On the other hand, zoxide's database is a binary format, because it's optimized for speed.

This location is based on a standard called the XDG Base Directory Specification. There's a good summary of it on the Arch Wiki. The Debian Wiki has a table to help you decide where to store a given file:

? DATA CONFIG STATE CACHE RUNTIME
sync across machines? yes? yes no no no
manage in VCS (Git/SVN)? no yes no no no
should be backed up? yes yes yes no no
can live in tmpfs? no no no yes yes?
contains much data? yes no no yes no

@dufferzafar
Copy link

@ajeetdsouza What is the data format of .zo file? Is it SQLite? or something custom?

@ajeetdsouza
Copy link
Owner

ajeetdsouza commented Nov 7, 2021

It's a custom binary format based on bincode. You can access zoxide's data via the CLI -- for example, zoxide query --all -ls would give you all the data in the database.

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

3 participants