diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2021-06-19 09:27:27 +0100 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2021-06-19 09:27:27 +0100 |
| commit | 01b48b3cd44cd08612c6b033b50feae2c96ff6e8 (patch) | |
| tree | f4331e09c669209b56b7448f930dd7d6286334c8 /dotfiles-darwin/zsh | |
| parent | b77fe30d8784ee494ef69de887fd224bcc6d441b (diff) | |
zsh: Move the ‘vault’ function to dotfiles-darwin
Diffstat (limited to 'dotfiles-darwin/zsh')
| -rw-r--r-- | dotfiles-darwin/zsh/functions/_vault | 3 | ||||
| -rw-r--r-- | dotfiles-darwin/zsh/functions/vault | 19 | ||||
| -rw-r--r-- | dotfiles-darwin/zsh/rc | 2 |
3 files changed, 24 insertions, 0 deletions
diff --git a/dotfiles-darwin/zsh/functions/_vault b/dotfiles-darwin/zsh/functions/_vault new file mode 100644 index 0000000..5cab4e5 --- /dev/null +++ b/dotfiles-darwin/zsh/functions/_vault @@ -0,0 +1,3 @@ +#compdef vault + +_arguments ": :(close open)" ": :_path_files" 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 diff --git a/dotfiles-darwin/zsh/rc b/dotfiles-darwin/zsh/rc index 0971457..b36f8ae 100644 --- a/dotfiles-darwin/zsh/rc +++ b/dotfiles-darwin/zsh/rc @@ -1,5 +1,7 @@ # -*- mode: shell-script -*- +autoload -Uz vault + alias df='df -Ph' alias ls='ls -G' alias lsh='du -a | sort -h' |
