Advertisement
Guest User

Untitled

a guest
May 29th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. # AV Plugin from:
  2. #
  3. export __AV_PROMPT_DIR=$ZSH/plugins/av
  4.  
  5. # Allow for functions in the prompt.
  6. setopt PROMPT_SUBST
  7.  
  8. ## Enable auto-execution of functions.
  9. typeset -ga preexec_functions
  10. typeset -ga precmd_functions
  11. typeset -ga chpwd_functions
  12.  
  13. # Append git functions needed for prompt.
  14. preexec_functions+='preexec_update_av_vars'
  15. precmd_functions+='precmd_update_av_vars'
  16. chpwd_functions+='chpwd_update_av_vars'
  17.  
  18. ## Function definitions
  19. function preexec_update_av_vars() {
  20. case "$2" in
  21. git*)
  22. __EXECUTED_AV_COMMAND=1
  23. ;;
  24. esac
  25. }
  26.  
  27. function precmd_update_av_vars() {
  28. if [ -n "$__EXECUTED_AV_COMMAND" ]; then
  29. update_current_av_vars
  30. unset __EXECUTED_AV_COMMAND
  31. fi
  32. }
  33.  
  34. function chpwd_update_av_vars() {
  35. update_current_av_vars
  36. }
  37.  
  38. function update_current_av_vars() {
  39. unset __CURRENT_AV_STATUS
  40.  
  41. _AV_STATUS=`av status`
  42. if [ ! -z ${_AV_STATUS} ]; then
  43. __CURRENT_AV_STATUS="av"
  44. fi
  45. }
  46.  
  47. function prompt_av_info() {
  48. if [ ! -z "$__CURRENT_AV_STATUS" ]; then
  49. echo "%{${fg[green]}%}$__CURRENT_AV_STATUS%{${fg[default]}%}"
  50. fi
  51. }
  52.  
  53. # Set the prompt.
  54. RPROMPT='$(prompt_av_info)'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement