2022-03-26 22:10:56 +08:00
|
|
|
#compdef opswd
|
|
|
|
|
|
|
|
function _opswd() {
|
|
|
|
local -a services
|
2022-03-26 22:11:04 +08:00
|
|
|
services=("${(@f)$(op item list --categories Login --cache 2>/dev/null | awk 'NR != 1 { print $2 }')}")
|
2022-03-26 22:10:56 +08:00
|
|
|
[[ -z "$services" ]] || compadd -a -- services
|
|
|
|
}
|
|
|
|
|
2022-03-26 22:11:04 +08:00
|
|
|
# TODO: 2022-03-26: Remove support for op CLI 1
|
|
|
|
autoload -Uz is-at-least
|
|
|
|
is-at-least 2.0.0 $(op --version) || {
|
|
|
|
function _opswd() {
|
|
|
|
local -a services
|
|
|
|
services=("${(@f)$(op list items --categories Login 2>/dev/null | op get item - --fields title 2>/dev/null)}")
|
|
|
|
[[ -z "$services" ]] || compadd -a -- services
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-26 22:10:56 +08:00
|
|
|
_opswd "$@"
|