Guest User

Untitled

a guest
May 27th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. ####
  2. #### pyenv-virtualenv bash prompt customization
  3. ####
  4.  
  5.  
  6. # pyenv
  7. eval "$(pyenv init -)"
  8.  
  9. # pyenv-virtualenv:
  10. eval "$(pyenv virtualenv-init -)"
  11. export PYENV_VIRTUALENV_DISABLE_PROMPT=1
  12. pyenvVirtualenvUpdatePrompt() {
  13. RED='\[\e[0;31m\]'
  14. GREEN='\[\e[0;32m\]'
  15. BLUE='\[\e[0;34m\]'
  16. RESET='\[\e[0m\]'
  17. [ -z "$PYENV_VIRTUALENV_ORIGINAL_PS1" ] && export PYENV_VIRTUALENV_ORIGINAL_PS1="$PS1"
  18. [ -z "$PYENV_VIRTUALENV_GLOBAL_NAME" ] && export PYENV_VIRTUALENV_GLOBAL_NAME="$(pyenv global)"
  19. VENV_NAME="$(pyenv version-name)"
  20. VENV_NAME="${VENV_NAME##*/}"
  21. GLOBAL_NAME="$PYENV_VIRTUALENV_GLOBAL_NAME"
  22.  
  23. # non-global versions:
  24. COLOR="$BLUE"
  25. # global version:
  26. [ "$VENV_NAME" == "$GLOBAL_NAME" ] && COLOR="$RED"
  27. # virtual envs:
  28. [ "${VIRTUAL_ENV##*/}" == "$VENV_NAME" ] && COLOR="$GREEN"
  29.  
  30. if [ -z "$COLOR" ]; then
  31. PS1="$PYENV_VIRTUALENV_ORIGINAL_PS1"
  32. else
  33. PS1="($COLOR${VENV_NAME}$RESET)$PYENV_VIRTUALENV_ORIGINAL_PS1"
  34. fi
  35. export PS1
  36. }
  37. export PROMPT_COMMAND="$PROMPT_COMMAND pyenvVirtualenvUpdatePrompt;"
  38.  
  39. ## Recommanded pyenv setup:
  40. ## run this once, don't put it in .bash_profile (or similar) files!
  41. # $ pyenv global system
  42. # $ cd $HOME
  43. # $ pyenv local 2.7.11 # or which ever version you like having as default
Add Comment
Please, Sign In to add comment