Update database
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?
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.
Thanks for your reply @ajeetdsouza! That would indeed be great I think!
@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.
For anyone finding this issue with a similar problem (migrating from Linux to MacOS and therefore different paths) my workaround was as follows:
- Export all directories via
zoxide query --allon my old machine - Running a search and replace over the output.
- 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"
Closing in favour of https://github.com/ajeetdsouza/zoxide/issues/453.