A Swift CLI that wraps keepassxc-cli to provide password manager integration for iTerm2.
This project uses Swift Package Manager and is organized into two modules:
-
PasswordManagerProtocol - Protocol data structures (shared with iTerm2)
- Located in
Sources/PasswordManagerProtocol/ - Can be included directly in iTerm2's Xcode project
- Located in
-
iterm2-keepassxc-adapter - CLI implementation specific to KeePassXC
- Located in
Sources/iterm2-keepassxc-adapter/ - Imports and uses PasswordManagerProtocol
- Located in
Build for release:
./build.shOr build for debugging:
swift buildThis creates the executable at .build/debug/iterm2-keepassxc-adapter (or .build/release/iterm2-keepassxc-adapter)
You can use the wrapper script which automatically builds if needed:
./iterm2-keepassxc-adapter <command>Or run the compiled binary directly:
.build/debug/iterm2-keepassxc-adapter <command>Set the database path via environment variable:
export KEEPASSXC_DATABASE="/path/to/database.kdbx"Then use JSON-based commands:
echo '{"iTermVersion":"3.5.0","minProtocolVersion":0,"maxProtocolVersion":0}' | ./iterm2-keepassxc-adapter handshake
echo '{"masterPassword":"your-password"}' | ./iterm2-keepassxc-adapter login- handshake - Protocol version negotiation
- login - Authenticate with master password
- list-accounts - List all entries in the database
- get-password - Retrieve password for an entry
- set-password - Update password for an entry
- add-account - Create new entry
- delete-account - Delete entry (moves to Recycle Bin)
Run all tests through Swift Package Manager:
swift testOr run the shell script directly:
./run_all_tests.shRun individual tests:
./test_handshake.sh
./test_login.sh
./test_list_accounts.sh
./test_get_password.sh
./test_set_password.sh
./test_add_account.sh
./test_delete_account.sh
./test_integration.shTo integrate with iTerm2:
- Add the PasswordManagerProtocol module to the iTerm2 Xcode project
- Include
Sources/PasswordManagerProtocol/PasswordManagerProtocol.swift
- Include
- Import and use the protocol structures for JSON encoding/decoding:
import PasswordManagerProtocol - Call the
iterm2-keepassxc-adapterexecutable with appropriate JSON input/output
The protocol structures are shared between the CLI and iTerm2, ensuring type safety and compatibility.