]> git.rmz.io Git - dotfiles.git/commitdiff
add script used to refactor password-store
authorSamir Benmendil <samir.benmendil@gmail.com>
Sun, 5 Jan 2014 23:32:46 +0000 (00:32 +0100)
committerSamir Benmendil <samir.benmendil@gmail.com>
Sun, 5 Jan 2014 23:32:46 +0000 (00:32 +0100)
bin/old/refactor_password-store.sh [new file with mode: 0755]

diff --git a/bin/old/refactor_password-store.sh b/bin/old/refactor_password-store.sh
new file mode 100755 (executable)
index 0000000..699488a
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+while read p; do
+    multi="$(pass "$p")"
+    username=$(echo -e "$multi" | sed -n 's/username: //p')
+    url=$(echo -e "$multi" | sed -n -e 's/url: //p')
+    urlstrip=$(echo "$url" | sed -re "s,([^/]*//)?([^@]*@)?(www\.)?([^:/]*).*,\4,")
+    if [[ -n "$url" && -n "$username" ]]; then
+        newfile="$urlstrip/$username.gpg"
+        if [[ -f "$newfile" ]]; then
+            echo "$newfile" already exists... skipping "$p"
+        else
+            mkdir "$urlstrip"
+            git mv "$p.gpg" "$newfile"
+        fi
+    fi
+done < list