From b0a22e0b97b0234655a78cbc44d8bbedc0f6397d Mon Sep 17 00:00:00 2001 From: Mattia Rigotti Date: Fri, 4 Oct 2019 12:50:06 -0400 Subject: [PATCH] In themes/sexy add option to visualize python environment --- themes/sexy/sexy.theme.bash | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/themes/sexy/sexy.theme.bash b/themes/sexy/sexy.theme.bash index 08869a3b..4250c540 100644 --- a/themes/sexy/sexy.theme.bash +++ b/themes/sexy/sexy.theme.bash @@ -1,6 +1,10 @@ # Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt" # Screenshot: http://cloud.gf3.ca/M5rG # A big thanks to \amethyst on Freenode +# +# Configuration: +# * To visualize python environment (virtualenv and conda) add in your .bash_profile the following line: +# export SEXY_WITH_PYTHON=true if tput setaf 1 &> /dev/null; then if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then @@ -34,9 +38,16 @@ parse_git_dirty () { parse_git_branch () { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" } +env_prompt () { + echo -e "($(virtualenv_prompt)$(condaenv_prompt))" +} function prompt_command() { PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]" + + if [ "$SEXY_WITH_PYTHON" = true ] ; then + PS1="\[${BOLD}${WHITE}\]$(env_prompt) "$PS1 + fi } safe_append_prompt_command prompt_command