Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
25d0b2df
Unverified
Commit
25d0b2df
authored
May 21, 2020
by
wurza
Committed by
GitHub
May 21, 2020
Browse files
man: look for man page for subcommands (#8798)
parent
fcd0747b
Changes
1
Show whitespace changes
Inline
Side-by-side
plugins/man/man.plugin.zsh
View file @
25d0b2df
...
...
@@ -16,16 +16,22 @@ man-command-line() {
# 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
# if typed command begins with man, do nothing
[[
"
$BUFFER
"
=
man
\
*
]]
&&
return
# get command and possible subcommand
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
[[
"
$BUFFER
"
!=
man
\
*
]]
&&
BUFFER
=
"man
${${
(Az)BUFFER
}
[1]
}
"
local
-a
args
args
=(
${${
(Az)BUFFER
}
[1]
}
${${
(Az)BUFFER
}
[2]
}
)
# check if man page exists for command and first argument
if
man
"
${
args
[1]
}
-
${
args
[2]
}
"
>
/dev/null 2>&1
;
then
BUFFER
=
"man
$args
"
else
BUFFER
=
"man
${
args
[1]
}
"
fi
}
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
# the .zshrc
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment