From f400ea1e57ef00d9bef6fa77206ee9c1997eb1d3 Mon Sep 17 00:00:00 2001 From: wurza Date: Mon, 16 Mar 2020 12:47:15 +0100 Subject: [PATCH] man: use only first element of command before prepending man (#8747) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michael Wurzer Co-authored-by: Marc Cornellà --- plugins/man/man.plugin.zsh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/man/man.plugin.zsh b/plugins/man/man.plugin.zsh index 94aa4918d..3ab15d323 100644 --- a/plugins/man/man.plugin.zsh +++ b/plugins/man/man.plugin.zsh @@ -13,8 +13,12 @@ # ------------------------------------------------------------------------------ man-command-line() { - [[ -z $BUFFER ]] && zle up-history - [[ $BUFFER != man\ * ]] && LBUFFER="man $LBUFFER" + # if there is no command typed, use the last command + [[ -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 # Defined shortcut keys: [Esc]man