Last active
February 10, 2021 14:49
-
-
Save frehder/7cb17e014a68839e2df06363f5d96e15 to your computer and use it in GitHub Desktop.
Get 1Password document items from list with "op" CLI tool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# jq json tool by https://stedolan.github.io/jq/ | |
# install: $ brew install jq | |
echo 'Using jq json tool:' | |
which jq | |
# 1password login | |
eval $(op signin $NAME) | |
# get data | |
while IFS= read -r line; do | |
uuid=$(echo ${line} | jq '.uuid' | tr -d '"') | |
title=$(echo ${line} | jq '.title' | tr -d '"') | |
echo "File: $title" | |
op get document $uuid > "docs/$title" | |
done < "$1" | |
# invoke: $ bash 1password-documents.bash document-list.json | |
# document-list.json has to have a newline at the end! | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"uuid": "someuuidfromonepassworditem","title": "This is an email.eml"} | |
{"uuid": "someotheruuidfromitem","title": "A pdf is fine too.pdf"} | |
{"uuid": "andanotheruuidfromitem","title": "This is an image - with a dash in the name.png"} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A better / easier version with instructions on how to use this:
https://github.com/frehder/1password-documents-backup