From 92d7e29125454a60953e4a977f245403418a27ac Mon Sep 17 00:00:00 2001 From: Mattia Rigotti Date: Fri, 27 Sep 2019 14:22:01 -0400 Subject: [PATCH 1/7] Add theme/sexy-python, a modified version of sexy which shows in which virtualenv or condaenv you are --- themes/sexy-python/sexy-python.theme.bash | 46 +++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 themes/sexy-python/sexy-python.theme.bash diff --git a/themes/sexy-python/sexy-python.theme.bash b/themes/sexy-python/sexy-python.theme.bash new file mode 100644 index 00000000..e472218a --- /dev/null +++ b/themes/sexy-python/sexy-python.theme.bash @@ -0,0 +1,46 @@ +# Small modification of Sexy Bash Prompt to include virtualenv and condaenv prompts +# (Sexy Bash Prompt is inspired by "Extravagant Zsh Prompt" +# with big thanks to \amethyst on Freenode) + +if tput setaf 1 &> /dev/null; then + if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then + MAGENTA=$(tput setaf 9) + ORANGE=$(tput setaf 172) + GREEN=$(tput setaf 190) + PURPLE=$(tput setaf 141) + WHITE=$(tput setaf 0) + else + MAGENTA=$(tput setaf 5) + ORANGE=$(tput setaf 4) + GREEN=$(tput setaf 2) + PURPLE=$(tput setaf 1) + WHITE=$(tput setaf 7) + fi + BOLD=$(tput bold) + RESET=$(tput sgr0) +else + MAGENTA="\033[1;31m" + ORANGE="\033[1;33m" + GREEN="\033[1;32m" + PURPLE="\033[1;35m" + WHITE="\033[1;37m" + BOLD="" + RESET="\033[m" +fi + +parse_git_dirty () { + [[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" +} +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}${WHITE}\]$(env_prompt) \[${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\]" +} + +safe_append_prompt_command prompt_command From 8b7333cd299135ce175d293d495f12ccf0a0377f Mon Sep 17 00:00:00 2001 From: Mattia Rigotti Date: Fri, 27 Sep 2019 14:22:01 -0400 Subject: [PATCH 2/7] Add theme/sexy-python, a modified version of sexy which shows in which virtualenv or condaenv you are --- themes/sexy-python/sexy-python.theme.bash | 46 +++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 themes/sexy-python/sexy-python.theme.bash diff --git a/themes/sexy-python/sexy-python.theme.bash b/themes/sexy-python/sexy-python.theme.bash new file mode 100644 index 00000000..e472218a --- /dev/null +++ b/themes/sexy-python/sexy-python.theme.bash @@ -0,0 +1,46 @@ +# Small modification of Sexy Bash Prompt to include virtualenv and condaenv prompts +# (Sexy Bash Prompt is inspired by "Extravagant Zsh Prompt" +# with big thanks to \amethyst on Freenode) + +if tput setaf 1 &> /dev/null; then + if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then + MAGENTA=$(tput setaf 9) + ORANGE=$(tput setaf 172) + GREEN=$(tput setaf 190) + PURPLE=$(tput setaf 141) + WHITE=$(tput setaf 0) + else + MAGENTA=$(tput setaf 5) + ORANGE=$(tput setaf 4) + GREEN=$(tput setaf 2) + PURPLE=$(tput setaf 1) + WHITE=$(tput setaf 7) + fi + BOLD=$(tput bold) + RESET=$(tput sgr0) +else + MAGENTA="\033[1;31m" + ORANGE="\033[1;33m" + GREEN="\033[1;32m" + PURPLE="\033[1;35m" + WHITE="\033[1;37m" + BOLD="" + RESET="\033[m" +fi + +parse_git_dirty () { + [[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" +} +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}${WHITE}\]$(env_prompt) \[${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\]" +} + +safe_append_prompt_command prompt_command From b0a22e0b97b0234655a78cbc44d8bbedc0f6397d Mon Sep 17 00:00:00 2001 From: Mattia Rigotti Date: Fri, 4 Oct 2019 12:50:06 -0400 Subject: [PATCH 3/7] 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 From ed47edcb06079642ee1e28ea0ea46d7b9005c4e4 Mon Sep 17 00:00:00 2001 From: Mattia Rigotti Date: Fri, 4 Oct 2019 12:51:23 -0400 Subject: [PATCH 4/7] Remove themes/sexy-python (it is now integrated in themes/sexy) --- themes/sexy-python/sexy-python.theme.bash | 46 ----------------------- 1 file changed, 46 deletions(-) delete mode 100644 themes/sexy-python/sexy-python.theme.bash diff --git a/themes/sexy-python/sexy-python.theme.bash b/themes/sexy-python/sexy-python.theme.bash deleted file mode 100644 index e472218a..00000000 --- a/themes/sexy-python/sexy-python.theme.bash +++ /dev/null @@ -1,46 +0,0 @@ -# Small modification of Sexy Bash Prompt to include virtualenv and condaenv prompts -# (Sexy Bash Prompt is inspired by "Extravagant Zsh Prompt" -# with big thanks to \amethyst on Freenode) - -if tput setaf 1 &> /dev/null; then - if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then - MAGENTA=$(tput setaf 9) - ORANGE=$(tput setaf 172) - GREEN=$(tput setaf 190) - PURPLE=$(tput setaf 141) - WHITE=$(tput setaf 0) - else - MAGENTA=$(tput setaf 5) - ORANGE=$(tput setaf 4) - GREEN=$(tput setaf 2) - PURPLE=$(tput setaf 1) - WHITE=$(tput setaf 7) - fi - BOLD=$(tput bold) - RESET=$(tput sgr0) -else - MAGENTA="\033[1;31m" - ORANGE="\033[1;33m" - GREEN="\033[1;32m" - PURPLE="\033[1;35m" - WHITE="\033[1;37m" - BOLD="" - RESET="\033[m" -fi - -parse_git_dirty () { - [[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" -} -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}${WHITE}\]$(env_prompt) \[${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\]" -} - -safe_append_prompt_command prompt_command From 08785d96b574fa93f43a55c968edac697bbe33f3 Mon Sep 17 00:00:00 2001 From: Mattia Rigotti Date: Sat, 12 Oct 2019 11:48:51 +0200 Subject: [PATCH 5/7] Delete stand-alone theme sexy-python --- themes/sexy-python/sexy-python.theme.bash | 46 ----------------------- 1 file changed, 46 deletions(-) delete mode 100644 themes/sexy-python/sexy-python.theme.bash diff --git a/themes/sexy-python/sexy-python.theme.bash b/themes/sexy-python/sexy-python.theme.bash deleted file mode 100644 index e472218a..00000000 --- a/themes/sexy-python/sexy-python.theme.bash +++ /dev/null @@ -1,46 +0,0 @@ -# Small modification of Sexy Bash Prompt to include virtualenv and condaenv prompts -# (Sexy Bash Prompt is inspired by "Extravagant Zsh Prompt" -# with big thanks to \amethyst on Freenode) - -if tput setaf 1 &> /dev/null; then - if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then - MAGENTA=$(tput setaf 9) - ORANGE=$(tput setaf 172) - GREEN=$(tput setaf 190) - PURPLE=$(tput setaf 141) - WHITE=$(tput setaf 0) - else - MAGENTA=$(tput setaf 5) - ORANGE=$(tput setaf 4) - GREEN=$(tput setaf 2) - PURPLE=$(tput setaf 1) - WHITE=$(tput setaf 7) - fi - BOLD=$(tput bold) - RESET=$(tput sgr0) -else - MAGENTA="\033[1;31m" - ORANGE="\033[1;33m" - GREEN="\033[1;32m" - PURPLE="\033[1;35m" - WHITE="\033[1;37m" - BOLD="" - RESET="\033[m" -fi - -parse_git_dirty () { - [[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" -} -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}${WHITE}\]$(env_prompt) \[${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\]" -} - -safe_append_prompt_command prompt_command From a50a4ff633bed3ac27bd761f3e86889750696549 Mon Sep 17 00:00:00 2001 From: Mattia Rigotti Date: Sat, 12 Oct 2019 11:50:54 +0200 Subject: [PATCH 6/7] Rename variable to SEXY_THEME_SHOW_PYTHON --- themes/sexy/sexy.theme.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/sexy/sexy.theme.bash b/themes/sexy/sexy.theme.bash index 4250c540..fdbbf83d 100644 --- a/themes/sexy/sexy.theme.bash +++ b/themes/sexy/sexy.theme.bash @@ -4,7 +4,7 @@ # # Configuration: # * To visualize python environment (virtualenv and conda) add in your .bash_profile the following line: -# export SEXY_WITH_PYTHON=true +# export SEXY_THEME_SHOW_PYTHON=true if tput setaf 1 &> /dev/null; then if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then @@ -45,7 +45,7 @@ env_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 + if [ "$SEXY_THEME_SHOW_PYTHON" = true ] ; then PS1="\[${BOLD}${WHITE}\]$(env_prompt) "$PS1 fi } From 05ded884658defde0fbc160a9d718f35f33bf845 Mon Sep 17 00:00:00 2001 From: Mattia Rigotti Date: Sat, 12 Oct 2019 11:52:53 +0200 Subject: [PATCH 7/7] Set SEXY_THEME_SHOW_PYTHON variable default value --- themes/sexy/sexy.theme.bash | 3 +++ 1 file changed, 3 insertions(+) diff --git a/themes/sexy/sexy.theme.bash b/themes/sexy/sexy.theme.bash index fdbbf83d..41d195d2 100644 --- a/themes/sexy/sexy.theme.bash +++ b/themes/sexy/sexy.theme.bash @@ -6,6 +6,9 @@ # * To visualize python environment (virtualenv and conda) add in your .bash_profile the following line: # export SEXY_THEME_SHOW_PYTHON=true +# Default setting +SEXY_THEME_SHOW_PYTHON="${SEXY_THEME_SHOW_PYTHON:=false}" + if tput setaf 1 &> /dev/null; then if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then MAGENTA=$(tput setaf 9)