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