sudo.plugin.zsh 594 B

123456789101112131415161718192021
  1. # ------------------------------------------------------------------------------
  2. # Description
  3. # -----------
  4. #
  5. # sudo will be inserted before the command
  6. #
  7. # ------------------------------------------------------------------------------
  8. # Authors
  9. # -------
  10. #
  11. # * Dongweiming <ciici123@gmail.com>
  12. #
  13. # ------------------------------------------------------------------------------
  14. sudo-command-line() {
  15. [[ -z $BUFFER ]] && zle up-history
  16. [[ $BUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER"
  17. }
  18. zle -N sudo-command-line
  19. # Defined shortcut keys: [Esc] [Esc]
  20. bindkey "\e\e" sudo-command-line