man.plugin.zsh 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. # ------------------------------------------------------------------------------
  2. # Author
  3. # ------
  4. #
  5. # * Jerry Ling<jerryling315@gmail.com>
  6. #
  7. # ------------------------------------------------------------------------------
  8. # Usage
  9. # -----
  10. #
  11. # man will be inserted before the command
  12. #
  13. # ------------------------------------------------------------------------------
  14. man-command-line() {
  15. # if there is no command typed, use the last command
  16. [[ -z "$BUFFER" ]] && zle up-history
  17. # prepend man to only the first part of the typed command
  18. # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
  19. [[ "$BUFFER" != man\ * ]] && BUFFER="man ${${(Az)BUFFER}[1]}"
  20. }
  21. zle -N man-command-line
  22. # Defined shortcut keys: [Esc]man
  23. bindkey "\e"man man-command-line
  24. # ------------------------------------------------------------------------------
  25. # Also, you might want to use man-preview included in 'osx' plugin
  26. # just substitute "man" in the function with "man-preview" after you included OS X in
  27. # the .zshrc