-
-
Save tyom/e7b2a25373ccea26671012f5b6333030 to your computer and use it in GitHub Desktop.
Optional 1Password CLI wrapper for op
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env sh | |
| # op: if 1Password CLI is installed, delegate to it; | |
| # otherwise, run the command after `--` unchanged. | |
| if command -v op >/dev/null 2>&1; then | |
| exec op "$@" | |
| fi | |
| # Skip args until `--`, then run the remainder. | |
| while [ "$#" -gt 0 ]; do | |
| [ "$1" = "--" ] && shift && break | |
| shift | |
| done | |
| if [ "$#" -eq 0 ]; then | |
| echo "op: nothing to run (expected -- <cmd> ...)" >&2 | |
| exit 2 | |
| fi | |
| exec "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment