20_zle.zsh 423 B

12345678910111213141516171819
  1. #
  2. # Zle config
  3. #
  4. # autoescape specials chars with urls
  5. autoload -U url-quote-magic
  6. zle -N self-insert url-quote-magic
  7. # insert sudo at beggining of current command
  8. insert-sudo-prefix () {
  9. local prefix
  10. prefix='sudo'
  11. if [ "${BUFFER:0:${#prefix}}" != "$prefix" ]; then
  12. BUFFER="$prefix $BUFFER"
  13. CURSOR=$(($CURSOR + $#prefix + 1))
  14. fi
  15. }
  16. zle -N insert-sudo-prefix
  17. bindkey "^b" insert-sudo-prefix