From 01b48b3cd44cd08612c6b033b50feae2c96ff6e8 Mon Sep 17 00:00:00 2001 From: Grégoire Duchêne Date: Sat, 19 Jun 2021 09:27:27 +0100 Subject: zsh: Move the ‘vault’ function to dotfiles-darwin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dotfiles-darwin/zsh/functions/_vault | 3 +++ dotfiles-darwin/zsh/functions/vault | 19 +++++++++++++++++++ dotfiles-darwin/zsh/rc | 2 ++ zsh/functions/_vault | 3 --- zsh/functions/vault | 19 ------------------- zsh/rc | 2 +- 6 files changed, 25 insertions(+), 23 deletions(-) create mode 100644 dotfiles-darwin/zsh/functions/_vault create mode 100644 dotfiles-darwin/zsh/functions/vault delete mode 100644 zsh/functions/_vault delete mode 100644 zsh/functions/vault 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' diff --git a/zsh/functions/_vault b/zsh/functions/_vault deleted file mode 100644 index 5cab4e5..0000000 --- a/zsh/functions/_vault +++ /dev/null @@ -1,3 +0,0 @@ -#compdef vault - -_arguments ": :(close open)" ": :_path_files" diff --git a/zsh/functions/vault b/zsh/functions/vault deleted file mode 100644 index 8196772..0000000 --- a/zsh/functions/vault +++ /dev/null @@ -1,19 +0,0 @@ -# -*- 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/zsh/rc b/zsh/rc index 6770e19..4b49059 100644 --- a/zsh/rc +++ b/zsh/rc @@ -10,7 +10,7 @@ done } -autoload -Uz compinit op-ssh-add vault zmv +autoload -Uz compinit op-ssh-add zmv [[ ! -d ${XDG_CACHE_HOME}/zsh ]] && mkdir -p ${XDG_CACHE_HOME}/zsh zstyle ':completion:*' cache-path ${XDG_CACHE_HOME}/zsh/cache -- cgit v1.2.3-70-g09d2