keychain.plugin.zsh 839 B

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