aboutsummaryrefslogtreecommitdiff
path: root/.oh-my-zsh/plugins/man
diff options
context:
space:
mode:
authorMarvin Borner2019-03-05 01:09:01 +0100
committerMarvin Borner2019-03-05 01:09:01 +0100
commit55457187d18221e76bd12f0fb2cfab65c49b92fb (patch)
tree8db042d2d80710d54100c2709ad4332153ac848a /.oh-my-zsh/plugins/man
Initial commit
Diffstat (limited to '.oh-my-zsh/plugins/man')
-rw-r--r--.oh-my-zsh/plugins/man/README.md13
-rw-r--r--.oh-my-zsh/plugins/man/man.plugin.zsh27
2 files changed, 40 insertions, 0 deletions
diff --git a/.oh-my-zsh/plugins/man/README.md b/.oh-my-zsh/plugins/man/README.md
new file mode 100644
index 0000000..4601252
--- /dev/null
+++ b/.oh-my-zsh/plugins/man/README.md
@@ -0,0 +1,13 @@
+# Man plugin
+
+This plugin adds a shortcut to insert man before the previous command.
+
+To use it, add `man` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... man)
+```
+# Keyboard Shortcuts
+| Shortcut | Description |
+|-----------------------------------|------------------------------------------------------------------------|
+| <kbd>Esc</kbd> + man | add man before the previous command to see the manual for this command |
diff --git a/.oh-my-zsh/plugins/man/man.plugin.zsh b/.oh-my-zsh/plugins/man/man.plugin.zsh
new file mode 100644
index 0000000..94aa491
--- /dev/null
+++ b/.oh-my-zsh/plugins/man/man.plugin.zsh
@@ -0,0 +1,27 @@
+# ------------------------------------------------------------------------------
+# Author
+# ------
+#
+# * Jerry Ling<jerryling315@gmail.com>
+#
+# ------------------------------------------------------------------------------
+# Usage
+# -----
+#
+# man will be inserted before the command
+#
+# ------------------------------------------------------------------------------
+
+man-command-line() {
+ [[ -z $BUFFER ]] && zle up-history
+ [[ $BUFFER != man\ * ]] && LBUFFER="man $LBUFFER"
+}
+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