keychain.plugin.zsh 920 B

1234567891011121314151617181920212223242526272829303132
  1. (( $+commands[keychain] )) || return
  2. # Define SHORT_HOST if not defined (%m = host name up to first .)
  3. SHORT_HOST=${SHORT_HOST:-${(%):-%m}}
  4. function {
  5. local agents
  6. local -a identities
  7. local -a options
  8. local _keychain_env_sh
  9. local _keychain_env_sh_gpg
  10. # load agents to start.
  11. zstyle -s :omz:plugins:keychain agents agents
  12. # load identities to manage.
  13. zstyle -a :omz:plugins:keychain identities identities
  14. # load additional options
  15. zstyle -a :omz:plugins:keychain options options
  16. # start keychain...
  17. keychain ${^options:-} --agents ${agents:-gpg} ${^identities} --host $SHORT_HOST
  18. # Get the filenames to store/lookup the environment from
  19. _keychain_env_sh="$HOME/.keychain/$SHORT_HOST-sh"
  20. _keychain_env_sh_gpg="$HOME/.keychain/$SHORT_HOST-sh-gpg"
  21. # Source environment settings.
  22. [ -f "$_keychain_env_sh" ] && . "$_keychain_env_sh"
  23. [ -f "$_keychain_env_sh_gpg" ] && . "$_keychain_env_sh_gpg"
  24. }