summaryrefslogtreecommitdiff
path: root/dotfiles-darwin/zsh/functions/vault
diff options
context:
space:
mode:
Diffstat (limited to 'dotfiles-darwin/zsh/functions/vault')
-rw-r--r--dotfiles-darwin/zsh/functions/vault19
1 files changed, 19 insertions, 0 deletions
diff --git a/dotfiles-darwin/zsh/functions/vault b/dotfiles-darwin/zsh/functions/vault
new file mode 100644
index 0000000..8196772
--- /dev/null
+++ b/dotfiles-darwin/zsh/functions/vault
@@ -0,0 +1,19 @@
+# -*- mode: sh -*-
+
+case $1 in
+ close)
+ hdiutil unmount -quiet $2
+ ;;
+ open)
+ local session=$(op signin --raw)
+ if [[ -z ${session} ]]; then
+ return 1
+ fi
+ op get item ${2:t} --fields password --session ${session} \
+ | hdiutil attach -quiet -stdinpass $2
+ op signout --session ${session}
+ ;;
+ *)
+ return 1
+ ;;
+esac