my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.0 KiB

3 years ago
  1. # ------------------------------------------------------------------------------
  2. # Author
  3. # ------
  4. #
  5. # * Jerry Ling<[email protected]>
  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. # if typed command begins with man, do nothing
  18. [[ "$BUFFER" = man\ * ]] && return
  19. # get command and possible subcommand
  20. # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
  21. local -a args
  22. args=(${${(Az)BUFFER}[1]} ${${(Az)BUFFER}[2]})
  23. # check if man page exists for command and first argument
  24. if man "${args[1]}-${args[2]}" >/dev/null 2>&1; then
  25. BUFFER="man $args"
  26. else
  27. BUFFER="man ${args[1]}"
  28. fi
  29. }
  30. zle -N man-command-line
  31. # Defined shortcut keys: [Esc]man
  32. bindkey "\e"man man-command-line