vault-cli
Manage your code snippets from the terminal. List, search, copy, create, push, and delete snippets without leaving your editor.
Getting Started#
vault-cli is a Go binary that talks directly to your Vault instance. You need a Vault account and a CLI access token to get started.
Install
Download the binary via go install
Get a token
Generate a CLI token in settings
Authenticate
Run vault auth login --token
You need a Vault account to generate a CLI token. Sign up for free then go to settings → CLI access tokens.
Installation#
Install via go install — requires Go 1.21 or later.
go install github.com/yuricommits/vault-cli@latestThe binary is installed to $GOPATH/bin. Make sure this is in your $PATH.
Build from source
git clone https://github.com/yuricommits/vault-cli
cd vault-cli
go build -o vault .
sudo mv vault /usr/local/bin/Verify installation
vault --helpSupported platforms: Linux, macOS, Windows. Clipboard support requires xclip on Linux.
Authentication#
vault-cli uses token-based authentication. Tokens are generated from your Vault settings page and stored locally in ~/.config/vault/config.json.
Generate a token
- 1.Go to vault settings
- 2.Scroll to CLI Access Tokens
- 3.Enter a name (e.g. macbook, work-pc)
- 4.Click create — copy the token immediately, it won't be shown again
Login
vault auth login --token vlt_yourtokenLogin with custom URL (self-hosted)
vault auth login --token vlt_yourtoken --url https://your-vault.comCheck status
vault auth statusLogout
vault auth logoutCommands Reference#
All commands require authentication. Run vault auth login first.
List snippets
vault listList all your snippets showing ID, language, and title.
Search snippets
vault search <query>Search snippets by title, description, language, or code content.
vault search "debounce"Copy to clipboard
vault copy <id>Copy a snippet's code directly to your system clipboard. Falls back to printing to stdout if clipboard is unavailable.
vault copy a1b2c3d4-...Create a snippet
vault newInteractively create a new snippet from the terminal. Prompts for title, language, description, and code. Type END on a new line to finish entering code.
Push a file
vault push <file>Push a local file as a snippet. Language is auto-detected from the file extension.
--titleSnippet titlefilename--languageLanguage overrideauto-detect--descriptionSnippet description—vault push ./hooks/useDebounce.ts
vault push ./hooks/useDebounce.ts --title "useDebounce" --description "Debounce hook for React"Delete a snippet
vault delete <id>Delete a snippet. Prompts for confirmation unless --force is passed.
--forceSkip confirmation promptfalsevault delete a1b2c3d4-...
vault delete a1b2c3d4-... --forceConfiguration#
Config is stored at ~/.config/vault/config.json. You can edit it directly or use the CLI commands.
tokenstringCLI access token—base_urlstringBase URL of your Vault instancevault-two-lovat.vercel.appExample config
{
"token": "vlt_abc123...",
"base_url": "https://vault-two-lovat.vercel.app"
}Examples#
Push all TypeScript files in a folder
for f in ./utils/*.ts; do
vault push "$f"
doneSearch and copy in one step
# Find the snippet ID
vault search "debounce"
# Copy it
vault copy <id>Quickly save a script you just wrote
vault push ./cleanup.sh --title "DB cleanup script" --description "Removes stale sessions"Delete multiple snippets
vault delete <id1> --force
vault delete <id2> --forceTroubleshooting#
command not found: vaultMake sure $GOPATH/bin is in your $PATH. Add export PATH=$PATH:$(go env GOPATH)/bin to your shell profile.
not authenticatedRun vault auth login --token <token>. Generate a token from vault settings → CLI access tokens.
request failed: 401Your token may be revoked or expired. Generate a new one from settings and run vault auth login again.
clipboard not working on LinuxInstall xclip: sudo apt install xclip. The copy command falls back to printing to stdout if xclip is unavailable.
vault: command not found after go installRun go env GOPATH to find your Go binary path, then add it to PATH.
GitHub#
vault-cli is open source. Contributions, bug reports, and feature requests are welcome.
Source code
Browse the repository
Report a bug
Open an issue
Releases
View changelog
Pull requests
Contribute