Skip to content

Instantly share code, notes, and snippets.

@dennypradipta
Created November 5, 2021 03:57
Show Gist options
  • Save dennypradipta/f931618429881d9d16c22bd14d087c28 to your computer and use it in GitHub Desktop.
Save dennypradipta/f931618429881d9d16c22bd14d087c28 to your computer and use it in GitHub Desktop.
1Password Exporter to CSV so that you can import it in Bitwarden
#!/bin/bash
# You may need to install 1Password CLI tools first.
# (https://support.1password.com/command-line-getting-started/#set-up-the-command-line-tool)
# After you installed 1Password CLI tools, make sure you are logged in.
# (https://support.1password.com/command-line-getting-started/#get-started-with-the-command-line-tool)
# TODO: Log in using the CLI and check if login success or not
# Run eval $(op signin my) to log in into 1Password
# If login success, run the command below. If not, print "Login error, exiting..."
# Create file
FILE="1password-$(date "+%Y%m%d-%H%M%S").csv"
if [ -f "${FILE}" ]; then
echo "file already exists '$1'"
exit 1
fi
# Define items to print
ITEMS=$(op list items)
UUIDS=($(echo "${ITEMS}" | jq '.[] | .uuid' --raw-output))
ITEMS=()
# Append the data to the file
echo -ne "Exporting data (this may take a while)..."
printf "title,urls,username,password\n" >> "${FILE}"
for UUID in ${UUIDS[@]}; do
echo -e "$(op get item "${UUID}" --fields title,url,username,password --format CSV)" >> "${FILE}"
# Sleep as to not trigger rate limiter
sleep 0.5
done
# And we're done!
echo -e "\nData exported to ${FILE}!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment