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>
This commit is contained in:
wurza 2020-03-16 12:47:15 +01:00 committed by GitHub
parent 07e3236bc5
commit f400ea1e57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,8 +13,12 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
man-command-line() { man-command-line() {
[[ -z $BUFFER ]] && zle up-history # if there is no command typed, use the last command
[[ $BUFFER != man\ * ]] && LBUFFER="man $LBUFFER" [[ -z "$BUFFER" ]] && zle up-history
# prepend man to only the first part of the typed command
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
[[ "$BUFFER" != man\ * ]] && BUFFER="man ${${(Az)BUFFER}[1]}"
} }
zle -N man-command-line zle -N man-command-line
# Defined shortcut keys: [Esc]man # Defined shortcut keys: [Esc]man