Skip to content

Instantly share code, notes, and snippets.

@frehder
Last active February 10, 2021 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frehder/7cb17e014a68839e2df06363f5d96e15 to your computer and use it in GitHub Desktop.
Save frehder/7cb17e014a68839e2df06363f5d96e15 to your computer and use it in GitHub Desktop.
Get 1Password document items from list with "op" CLI tool
#!/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!
{"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"}
@frehder
Copy link
Author

frehder commented Feb 10, 2021

A better / easier version with instructions on how to use this:

https://github.com/frehder/1password-documents-backup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment