man: use only first element of command before prepending man (#8747)
Co-authored-by: Michael Wurzer <michael.wurzer@sequality.at>
Co-authored-by: Marc Cornellà <marc.cornella@live.com>
Diff
1diff --git a/plugins/man/man.plugin.zsh b/plugins/man/man.plugin.zsh
2index 94aa4918d8574174da7b2e20b32d29a64bdabae7..3ab15d32392839de92363b4f54412a59b0186fbb 100644
3--- a/plugins/man/man.plugin.zsh
4+++ b/plugins/man/man.plugin.zsh
5@@ -13,8 +13,12 @@
6 # ------------------------------------------------------------------------------
7 8 man-command-line() {
9- [[ -z $BUFFER ]] && zle up-history
10- [[ $BUFFER != man\ * ]] && LBUFFER="man $LBUFFER"
11+ # if there is no command typed, use the last command
12+ [[ -z "$BUFFER" ]] && zle up-history
13+
14+ # prepend man to only the first part of the typed command
15+ # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
16+ [[ "$BUFFER" != man\ * ]] && BUFFER="man ${${(Az)BUFFER}[1]}"
17 }
18 zle -N man-command-line
19 # Defined shortcut keys: [Esc]man