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.
- Windows 10 or later with WSL enabled.
- Zsh installed on your WSL distribution.
- Windows Package Manager (winget) installed on your Windows system.
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
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.
- Open your WSL terminal.
- Edit your .zshrc file using a text editor, for example, using nano:
nano ~/.zshrc
- 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"
- Test the alias by running the following command:
op --version
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.