A very simple bash function that helps find passwords using the 1Password CLI.
(This recording was made with terminalizer)
opp Github
If there is a single match for 'Github', the password will be copied to the clipboard. If no clipboard utility is found, the raw password can be displayed by using an explicit flag:
opp Github --reveal
NOTE: If the --reveal
flag is used, it disables clipboard functionality entirely and displays the raw password instead.
You can also extract TOTP (Time-based One-Time Password) codes:
opp Github --totp
This will copy the TOTP code to the clipboard, just like passwords.
If there are no matches, this is reported as an error.
If multiple matches are found, the items are provided as an indexed list. Use the index to get the specific item:
opp Github 2
An item can also be fetched with its full content:
opp Github 2 --raw
Or for a single match:
opp Github --raw
This will provide the item in JSON format.
You can also get TOTP codes from indexed matches:
opp Github 2 --totp
This script requires the following dependencies:
- 1Password CLI (op): Used to access your 1Password vault from the command line.
- jq: For parsing JSON output from the 1Password CLI.
- xclip (Linux) or
pbcopy
(macOS): For copying passwords to the clipboard.
sudo apt install jq xclip # Debian/Ubuntu
# OR
sudo dnf install jq xclip # Fedora
# Download and install 1Password CLI from https://developer.1password.com/docs/cli/get-started/
brew install 1password-cli
brew install jq
- Install 1Password CLI (download the Windows release and add it to your PATH).
- Install jq for Windows.
- For clipboard support, install Win32yank or use clip.exe (included in Windows 10+).
After installing dependencies, source the script in e.g. your Bash profile:
source /path/to/opp.sh