Skip to content

πŸ” A simple bash function for quick password access via 1Password CLI. Search, select, and copy passwords to clipboard with interactive indexing, TOTP support, and cross-platform compatibility.

Notifications You must be signed in to change notification settings

simontjell/OnePasswordBash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OnePasswordBash

A very simple bash function that helps find passwords using the 1Password CLI.

Demo (This recording was made with terminalizer)

Usage

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

Installation

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.

Install on Linux

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/

Install on macOS

brew install 1password-cli
brew install jq

Install on Windows

  1. Install 1Password CLI (download the Windows release and add it to your PATH).
  2. Install jq for Windows.
  3. For clipboard support, install Win32yank or use clip.exe (included in Windows 10+).

Sourcing the script

After installing dependencies, source the script in e.g. your Bash profile:

source /path/to/opp.sh

About

πŸ” A simple bash function for quick password access via 1Password CLI. Search, select, and copy passwords to clipboard with interactive indexing, TOTP support, and cross-platform compatibility.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages