zoxide icon indicating copy to clipboard operation
zoxide copied to clipboard

Update database

Open AckslD opened this issue 4 years ago • 4 comments

If I renamed some of my common directories, is it possible to edit the database in some way to reflect this without loosing the current scores?

AckslD avatar Jul 20 '21 13:07 AckslD

That's a somewhat niche use case, so there's no real way to do this at the moment. I'd recommend just running zoxide add . in the new directory a couple of times.

I do see how this could be necessary, though - perhaps a feature that allows you to open up the database in a human-readable form with your $EDITOR and save it back would be useful.

ajeetdsouza avatar Jul 20 '21 14:07 ajeetdsouza

Thanks for your reply @ajeetdsouza! That would indeed be great I think!

AckslD avatar Jul 20 '21 14:07 AckslD

@ajeetdsouza Would you reconsider #133? Once it's implemented, updating database can be archived via export -> edit -> import, and that can be implemented via simple shell scripts.

kidonng avatar Aug 05 '21 15:08 kidonng

For anyone finding this issue with a similar problem (migrating from Linux to MacOS and therefore different paths) my workaround was as follows:

  1. Export all directories via zoxide query --all on my old machine
  2. Running a search and replace over the output.
  3. Add the paths on my new machine with the following script. Of course I will loose my scores but I can live with that :)
#!/bin/bash

input="$HOME/Downloads/zoxide.txt"
if [[ -f "$_ZO_DATA_DIR/db.zo" ]]
then
  echo "WARNING zoxide db exists"
  echo "Continue?"
  select choice in "Yes" "No"; do
    case $choice in
      Yes ) echo "Going on"; break;;
      No ) exit;;
    esac
  done
fi

while IFS= read -r line
do
  if [[ ! -d "$line" ]]
  then
    echo "WARNING $line does not exist - not adding to database"
  else
    zoxide add "$line"
  fi
done < "$input"

Allaman avatar Dec 20 '21 10:12 Allaman

Closing in favour of https://github.com/ajeetdsouza/zoxide/issues/453.

ajeetdsouza avatar Sep 17 '22 19:09 ajeetdsouza