sudo.plugin.zsh 601 B

12345678910111213141516171819202122
  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\ * ]] && BUFFER="sudo $BUFFER"
  17. zle end-of-line
  18. }
  19. zle -N sudo-command-line
  20. # Defined shortcut keys: [Esc] [Esc]
  21. bindkey "\e\e" sudo-command-line