Skip to content

Instantly share code, notes, and snippets.

@brb
Created September 17, 2021 09:28
Embed
What would you like to do?
#!/usr/bin/env bash
# Copyright (C) 2013 Tom Hendrikx <tom@whyscream.net>. All Rights Reserved.
# This file is licensed under the GPLv2+. Please see COPYING for more information.
export=$1
IFS=" " # tab character
cat "$export" | while read uuid group name login passwd notes; do
test "$uuid" = "# passwordsafe version 2.0 database" && continue
test "$uuid" = "uuid" && continue
test "$name" = '""' && continue;
group="$(echo $group | cut -d'"' -f2)"
login="$(echo $login | cut -d'"' -f2)"
passwd="$(echo $passwd | cut -d'"' -f2)"
name="$(echo $name | cut -d'"' -f2)"
notes="$(echo $notes | cut -d'"' -f2)"
# cleanup
test "${name:0:4}" = "http" && name="$(echo $name | cut -d'/' -f3)"
test "${name:0:4}" = "www." && name="$(echo $name | cut -c 5-)"
entry=""
test -n "$passwd" && entry="${entry}$passwd\n"
test -n "$login" && entry="${entry}Username: $login\n"
test -n "$notes" && entry="${entry}${notes}\n"
echo Adding entry for $name:
echo -e $entry | pass insert --multiline --force "${group}/${name}"
test $? && echo "Added!"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment