man.plugin.zsh 1.02 KB
Newer Older
Jerry Ling's avatar
Jerry Ling committed
1
2
3
4
5
6
7
# ------------------------------------------------------------------------------
# Author
# ------
#
# * Jerry Ling<jerryling315@gmail.com>
#
# ------------------------------------------------------------------------------
8
# Usage
Jerry Ling's avatar
Jerry Ling committed
9
10
11
12
13
14
15
# -----
#
# man will be inserted before the command
#
# ------------------------------------------------------------------------------

man-command-line() {
16
17
18
19
20
21
    # 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]}"
Jerry Ling's avatar
Jerry Ling committed
22
23
24
25
26
27
28
29
30
}
zle -N man-command-line
# Defined shortcut keys: [Esc]man
bindkey "\e"man man-command-line


# ------------------------------------------------------------------------------
# Also, you might want to use man-preview included in 'osx' plugin
# just substitute "man" in the function with "man-preview" after you included OS X in
31
# the .zshrc