Skip to content

Instantly share code, notes, and snippets.

@PickleBoxer
Last active April 26, 2025 12:32
Show Gist options
  • Save PickleBoxer/3f3830a51f3586d4202f62b7c09346bc to your computer and use it in GitHub Desktop.
Save PickleBoxer/3f3830a51f3586d4202f62b7c09346bc to your computer and use it in GitHub Desktop.
1Password CLI on Windows Host Running on WSL

1Password CLI on Windows Host Running on WSL

This guide will walk you through the process of installing the 1Password Command Line Interface (CLI) on a Windows system and setting up an alias for it in the Windows Subsystem for Linux (WSL) using Zsh.

Prerequisites

  • Windows 10 or later with WSL enabled.
  • Zsh installed on your WSL distribution.
  • Windows Package Manager (winget) installed on your Windows system.

Installation Steps

Step 1: Install 1Password CLI

First, open a Windows PowerShell terminal as an administrator and run the following command to install the 1Password CLI using winget:

winget install 1password-cli

Cheack the installation by running the following command:

op --version

Step 2: Locate the 1Password CLI Executable

After installation, you need to find the path to the op.exe executable. Still in PowerShell, you can use the following command to search for it:

Get-Command op | Select-Object -ExpandProperty Source

Note

Note the path returned by this command.

Step 3: Add an Alias in Zsh

  1. Open your WSL terminal.
  2. Edit your .zshrc file using a text editor, for example, using nano:
nano ~/.zshrc
  1. At the bottom of the .zshrc file, add an alias that points to the 1Password CLI executable. You will need to add the actual path you noted earlier. Since this is a Windows path, you'll need to translate it to a path that WSL understands and ensure it's executable with wine if necessary or directly if you're using WSL 2 and can execute Windows binaries directly. An example alias (for WSL 2) might look like this:
# 1password-cli
alias op="/mnt/c/Users/xxxx/AppData/Local/Microsoft/WinGet/Links/op.exe"
  1. Test the alias by running the following command:
op --version

Conclusion

You've successfully installed the 1Password CLI on your Windows system and set up an alias for it in WSL using Zsh. This setup allows you to seamlessly integrate 1Password into your development workflow in the Windows Subsystem for Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment