20_zle.zsh 510 B

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