1 # ------------------------------------------------------------------------------
5 # * Jerry Ling<jerryling315@gmail.com>
7 # ------------------------------------------------------------------------------
11 # man will be inserted before the command
13 # ------------------------------------------------------------------------------
16 # if there is no command typed, use the last command
17 [[ -z "$BUFFER" ]] && zle up-history
19 # if typed command begins with man, do nothing
20 [[ "$BUFFER" = man\ * ]] && return
22 # get command and possible subcommand
23 # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
25 args=(${${(Az)BUFFER}[1]} ${${(Az)BUFFER}[2]})
27 # check if man page exists for command and first argument
28 if man "${args[1]}-${args[2]}" >/dev/null 2>&1; then
31 BUFFER="man ${args[1]}"
35 zle -N man-command-line
36 # Defined shortcut keys: [Esc]man
37 bindkey "\e"man man-command-line