mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-04-17 04:29:14 +02:00
feat(keyman): 更新 README 和插件文档,统一命令格式并增强帮助信息
This commit is contained in:
parent
4ae29045f2
commit
7cc680d82c
2 changed files with 358 additions and 156 deletions
|
|
@ -1,39 +1,89 @@
|
|||
# keyman plugin
|
||||
|
||||
Provides convenient commands for managing SSH and GPG keys from the terminal.
|
||||
Provides a unified `keyman` command for managing SSH and GPG keys from the terminal.
|
||||
Works on macOS, Linux (X11/Wayland), and WSL.
|
||||
|
||||
> **Relationship to other plugins:** The [`ssh-agent`](../ssh-agent) and
|
||||
> [`gpg-agent`](../gpg-agent) plugins manage agent *daemons* (auto-starting,
|
||||
> identity loading, forwarding). `keyman` focuses on key *lifecycle* — creating,
|
||||
> listing, copying, and deleting keys. They are complementary and can be used
|
||||
> together.
|
||||
|
||||
To enable it, add `keyman` to your plugins:
|
||||
|
||||
```zsh
|
||||
plugins=(... keyman)
|
||||
```
|
||||
|
||||
Then type `keyman` to see all available commands.
|
||||
Then type `keyman help` to see all available commands.
|
||||
|
||||
## Requirements
|
||||
|
||||
At least one of the following must be available:
|
||||
|
||||
- `ssh-keygen` — for SSH key commands
|
||||
- `gpg` — for GPG key commands
|
||||
|
||||
### Clipboard support
|
||||
|
||||
For clipboard commands (`keyman ssh copy`, `keyman gpg copy`), one of the tools
|
||||
below must be installed:
|
||||
|
||||
| Platform | Tool | Notes |
|
||||
| --------------- | ---------- | -------------------------- |
|
||||
| macOS | `pbcopy` | Built-in |
|
||||
| Linux (X11) | `xclip` | `apt install xclip` |
|
||||
| Linux (Wayland) | `wl-copy` | `apt install wl-clipboard` |
|
||||
| WSL | `clip.exe` | Built-in (Windows side) |
|
||||
|
||||
## Commands
|
||||
|
||||
### SSH
|
||||
|
||||
| Command | Description |
|
||||
|---|---|
|
||||
| `km-ssh-new [comment] [file] [type]` | Create a new SSH key (default: ed25519) |
|
||||
| `km-ssh-ls` | List all SSH public keys in `~/.ssh` |
|
||||
| `km-ssh-copy [pubkey_file]` | Copy a public key to clipboard |
|
||||
| `km-ssh-rm <keyfile>` | Delete an SSH key pair |
|
||||
| Command | Description |
|
||||
| --------------------------------------------- | --------------------------------------- |
|
||||
| `keyman ssh new [comment] [file] [type]` | Create a new SSH key (default: ed25519) |
|
||||
| `keyman ssh ls` | List all SSH public keys in `~/.ssh` |
|
||||
| `keyman ssh copy [pubkey_file]` | Copy a public key to clipboard |
|
||||
| `keyman ssh rm <keyfile>` | Delete an SSH key pair |
|
||||
|
||||
### GPG
|
||||
|
||||
| Command | Description |
|
||||
|---|---|
|
||||
| `km-gpg-new` | Create a GPG key (interactive, via `gpg --full-generate-key`) |
|
||||
| `km-gpg-quick-new "Name" "Email" [expiry]` | Create a GPG key non-interactively (ed25519, default 2y expiry) |
|
||||
| `km-gpg-ls [-s\|--secret]` | List public keys, or secret keys with `-s` |
|
||||
| `km-gpg-pub <id>` | Export a GPG public key (armored) |
|
||||
| `km-gpg-priv <id>` | Export a GPG secret key (armored, with confirmation) |
|
||||
| `km-gpg-copy <id>` | Copy a GPG public key to clipboard |
|
||||
| `km-gpg-fp <id>` | Show a GPG key fingerprint |
|
||||
| `km-gpg-rm <id>` | Delete a GPG key (secret + public) |
|
||||
| Command | Description |
|
||||
| -------------------------------------------------- | --------------------------------------------------------------- |
|
||||
| `keyman gpg new` | Create a GPG key (interactive, via `gpg --full-generate-key`) |
|
||||
| `keyman gpg quick-new "Name" "Email" [expiry]` | Create a GPG key non-interactively (ed25519, default 2y expiry) |
|
||||
| `keyman gpg ls [-s\|--secret]` | List public keys, or secret keys with `-s` |
|
||||
| `keyman gpg pub <id>` | Export a GPG public key (armored) |
|
||||
| `keyman gpg priv <id>` | Export a GPG secret key (armored, with confirmation) |
|
||||
| `keyman gpg copy <id>` | Copy a GPG public key to clipboard |
|
||||
| `keyman gpg fp <id>` | Show a GPG key fingerprint |
|
||||
| `keyman gpg rm <id>` | Delete a GPG key (secret + public) |
|
||||
|
||||
### General
|
||||
|
||||
| Command | Description |
|
||||
| -------------- | ----------------- |
|
||||
| `keyman help` | Show help message |
|
||||
|
||||
## Tab Completion
|
||||
|
||||
All commands support multi-level Zsh tab completion:
|
||||
|
||||
```
|
||||
keyman <TAB> → ssh | gpg | help
|
||||
keyman ssh <TAB> → new | ls | copy | rm
|
||||
keyman gpg <TAB> → new | quick-new | ls | pub | priv | copy | fp | rm
|
||||
```
|
||||
|
||||
At the argument level:
|
||||
|
||||
- **`keyman ssh new`** — completes key types (`ed25519`, `rsa`, `ecdsa`) and file paths
|
||||
- **`keyman ssh copy`** — completes `~/.ssh/*.pub` files
|
||||
- **`keyman ssh rm`** — completes private key files in `~/.ssh`
|
||||
- **`keyman gpg ls`** — completes `--secret` / `-s` options
|
||||
- **`keyman gpg quick-new`** — completes common expiry values (`1y`, `2y`, `3y`, `5y`, `0`)
|
||||
- **`keyman gpg pub`**, **`priv`**, **`copy`**, **`fp`**, **`rm`** — complete GPG key IDs and emails from your keyring
|
||||
|
||||
## Settings
|
||||
|
||||
|
|
@ -57,7 +107,7 @@ zstyle :omz:plugins:keyman debug true
|
|||
|
||||
### `default-ssh-type`
|
||||
|
||||
Set the default SSH key type for `km-ssh-new`. Supported values:
|
||||
Set the default SSH key type for `keyman ssh new`. Supported values:
|
||||
`ed25519` (default), `rsa`, `ecdsa`.
|
||||
|
||||
```zsh
|
||||
|
|
@ -68,30 +118,32 @@ zstyle :omz:plugins:keyman default-ssh-type rsa
|
|||
|
||||
```zsh
|
||||
# Create a default ed25519 key
|
||||
km-ssh-new
|
||||
keyman ssh new
|
||||
|
||||
# Create an RSA key with a custom comment and path
|
||||
km-ssh-new "me@work" ~/.ssh/work_key rsa
|
||||
keyman ssh new "me@work" ~/.ssh/work_key rsa
|
||||
|
||||
# List all SSH keys
|
||||
km-ssh-ls
|
||||
keyman ssh ls
|
||||
|
||||
# Copy the default public key to clipboard
|
||||
km-ssh-copy
|
||||
keyman ssh copy
|
||||
|
||||
# Delete an SSH key
|
||||
keyman ssh rm ~/.ssh/id_ed25519
|
||||
|
||||
# Create a GPG key interactively
|
||||
keyman gpg new
|
||||
|
||||
# Create a GPG key quickly
|
||||
km-gpg-quick-new "John Doe" "john@example.com" 1y
|
||||
keyman gpg quick-new "John Doe" "john@example.com" 1y
|
||||
|
||||
# List GPG secret keys
|
||||
keyman gpg ls --secret
|
||||
|
||||
# Export and copy a GPG public key
|
||||
km-gpg-copy john@example.com
|
||||
keyman gpg copy john@example.com
|
||||
|
||||
# Show GPG key fingerprint
|
||||
keyman gpg fp john@example.com
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
At least one of the following must be available:
|
||||
|
||||
- `ssh-keygen` -- for SSH key commands
|
||||
- `gpg` -- for GPG key commands
|
||||
|
||||
For clipboard support, one of: `pbcopy` (macOS), `xclip` (Linux X11),
|
||||
`wl-copy` (Linux Wayland), or `clip.exe` (WSL).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue