浏览代码

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>
wurza 5 年之前
父节点
当前提交
f400ea1e57
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      plugins/man/man.plugin.zsh

+ 6 - 2
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