_opswd 555 B

12345678910111213141516171819
  1. #compdef opswd
  2. function _opswd() {
  3. local -a services
  4. services=("${(@f)$(op item list --categories Login --cache 2>/dev/null | awk 'NR != 1 { print $2 }')}")
  5. [[ -z "$services" ]] || compadd -a -- services
  6. }
  7. # TODO: 2022-03-26: Remove support for op CLI 1
  8. autoload -Uz is-at-least
  9. is-at-least 2.0.0 $(op --version) || {
  10. function _opswd() {
  11. local -a services
  12. services=("${(@f)$(op list items --categories Login 2>/dev/null | op get item - --fields title 2>/dev/null)}")
  13. [[ -z "$services" ]] || compadd -a -- services
  14. }
  15. }
  16. _opswd "$@"