mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-09 02:24:03 +01:00
2.4 KiB
2.4 KiB
zsh-vi-man plugin
Smart man page lookup for zsh vi mode. Press K (Shift-K) on any command or option to instantly open its man page.
To use it, add zsh-vi-man to the plugins array in your zshrc file:
plugins=(... zsh-vi-man)
Features
- Smart Detection: Automatically finds the right man page for subcommands (e.g.,
git commit→man git-commit) - Option Jumping: Opens man page directly at the option definition (e.g.,
grep -r→ jumps to-rentry) - Combined Options: Works with combined short options (e.g.,
rm -rf→ finds both-rand-f) - Value Extraction: Handles options with values (e.g.,
--color=always→ searches--color) - Pipe Support: Detects correct command in pipelines (e.g.,
cat file | grep -i→ opensman grep) - Multiple Formats: Supports various man page styles (GNU, jq, find, etc.)
Usage
- Type a command (e.g.,
ls -laorgit commit --amend) - Press
Escapeto enter vi normal mode - Move cursor to any word
- Press
Kto open the man page
Examples
| Command | Cursor On | Result |
|---|---|---|
ls -la |
ls |
Opens man ls |
ls -la |
-la |
Opens man ls, jumps to -l |
git commit --amend |
commit |
Opens man git-commit |
grep --color=auto |
--color=auto |
Opens man grep, jumps to --color |
cat file | sort -r |
-r |
Opens man sort, jumps to -r |
find . -name "*.txt" |
-name |
Opens man find, jumps to -name |
Configuration
Set these variables before sourcing oh-my-zsh:
# Change the trigger key (default: K)
ZVM_MAN_KEY='?'
# Use a different pager (default: less)
ZVM_MAN_PAGER='bat'
Integration with zsh-vi-mode
This plugin works seamlessly with zsh-vi-mode. It automatically detects zsh-vi-mode and hooks into its lazy keybindings system.
For best results, ensure zsh-vi-mode is loaded before this plugin:
plugins=(... zsh-vi-mode zsh-vi-man)
Requirements
- zsh with vi mode enabled (built-in or via
vi-modeplugin) mancommand available
License
MIT License - see LICENSE for details.