From 5125fd57ef7d16526ebaf8df79712148b0e98d46 Mon Sep 17 00:00:00 2001 From: Diogo Alexsander Cavilha Date: Thu, 20 Jun 2019 16:05:07 -0300 Subject: [PATCH] Add Python virtual environment support - Add human-dark mode to the help text. - Fix light-double-line style. resolves #28 --- CHANGELOG.md | 6 ++++++ config.sh | 2 ++ help.sh | 1 + prompt_styles/dark-double-line.sh | 11 ++++++++++- prompt_styles/dark.sh | 11 ++++++++++- prompt_styles/default.sh | 11 ++++++++++- prompt_styles/fancy-double-line.sh | 11 ++++++++++- prompt_styles/human-dark.sh | 8 +++++++- prompt_styles/human.sh | 7 ++++++- prompt_styles/light-double-line.sh | 13 +++++++++++-- prompt_styles/light.sh | 11 ++++++++++- prompt_styles/simple-double-line.sh | 7 ++++++- prompt_styles/simple.sh | 7 ++++++- version.sh | 2 +- 14 files changed, 96 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 068009e..d15334a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Fancy Git Changelog +### v6.0.0 + +- Add Python virtual environment support. +- Add human-dark mode to the help text. +- Fix light-double-line style. + ### v5.3.0 - Add a sign for local branches only. diff --git a/config.sh b/config.sh index a930548..dd18a3c 100644 --- a/config.sh +++ b/config.sh @@ -129,6 +129,7 @@ local s_darkgray local s_lightgray_bgyellow s_lightmagenta_bgblue="${light_magenta}${bg_blue}${separator}${bg_none}${none}" +s_lightmagenta_bgdarkgray="${light_magenta}${bg_dark_gray}${separator}${bg_none}${none}" s_lightmagenta_bgnone="${light_magenta}${bg_none}${separator}${bg_none}${none}" s_blue_bglightyellow="${blue}${bg_light_yellow}${separator}${bg_none}${none}${bg_none}" s_blue_bglightgreen="${blue}${bg_light_green}${separator}${bg_none}${none}${bg_none}" @@ -138,6 +139,7 @@ s_yellow="${yellow}${separator}${none}" s_green="${light_green}${separator}${none}" s_white="${white}${separator}${none}" s_blue="${blue}${separator}${none}" +# s_blue_bgdarkgray="${blue}${bg_dark_gray}${separator}${none}" s_lightgray="${light_gray}${separator}${none}" s_darkgray="${dark_gray}${separator}${none}" s_dark_gray_bgnone="${dark_gray}${separator}${none}${bg_none}" diff --git a/help.sh b/help.sh index 010eab7..d113162 100644 --- a/help.sh +++ b/help.sh @@ -26,6 +26,7 @@ echo " Fancy Git v$FANCYGIT_VERSION - $fg_current_year by Diogo Alexsander Cavil fancygit default Change prompt to the default (colored) style. (This is the fallback style). fancygit double-line Change prompt to the default (colored) style in double line. fancygit human Change prompt to the human readable style. + fancygit human-dark Change prompt to the human readable style. fancygit dark Change prompt to the dark style. fancygit dark-double-line Change prompt to the dark style in double line. fancygit light Change prompt to the light style. diff --git a/prompt_styles/dark-double-line.sh b/prompt_styles/dark-double-line.sh index e5b5573..2cdac3f 100644 --- a/prompt_styles/dark-double-line.sh +++ b/prompt_styles/dark-double-line.sh @@ -79,7 +79,16 @@ fancygit_prompt_builder() { return fi - PS1="${prompt_user}${prompt_path}${prompt_symbol} " + local venv="" + + if ! [ -z ${VIRTUAL_ENV} ] + then + prompt_user="${user_at_host} \\u@\\h ${user_at_host_end}" + venv="`basename \"$VIRTUAL_ENV\"`" + venv="${bg_dark_gray}${bold}${white}${venv} ${path_end}${s_darkgray_bgdarkgray01}" + fi + + PS1="${venv}${prompt_user}${prompt_path}${prompt_symbol} " } PROMPT_COMMAND="fancygit_prompt_builder" diff --git a/prompt_styles/dark.sh b/prompt_styles/dark.sh index 37403eb..1d5d13e 100644 --- a/prompt_styles/dark.sh +++ b/prompt_styles/dark.sh @@ -79,7 +79,16 @@ fancygit_prompt_builder() { return fi - PS1="${prompt_user}${prompt_symbol}${prompt_path} " + local venv="" + + if ! [ -z ${VIRTUAL_ENV} ] + then + prompt_user="${user_at_host} \\u@\\h ${user_at_host_end}" + venv="`basename \"$VIRTUAL_ENV\"`" + venv="${bg_dark_gray}${bold}${white}${venv} ${path_end}${s_darkgray_bgdarkgray01}" + fi + + PS1="${venv}${prompt_user}${prompt_symbol}${prompt_path} " } PROMPT_COMMAND="fancygit_prompt_builder" diff --git a/prompt_styles/default.sh b/prompt_styles/default.sh index ef0084a..c2da0cd 100644 --- a/prompt_styles/default.sh +++ b/prompt_styles/default.sh @@ -79,7 +79,16 @@ fancygit_prompt_builder() { return fi - PS1="${prompt_user}${prompt_symbol}${prompt_path} " + local venv="" + + if ! [ -z ${VIRTUAL_ENV} ] + then + prompt_user="${user_at_host} \\u@\\h ${user_at_host_end}" + venv="`basename \"$VIRTUAL_ENV\"`" + venv="${bg_light_magenta}${bold}${white}${venv} ${path_end}${s_lightmagenta_bgdarkgray}" + fi + + PS1="${venv}${prompt_user}${prompt_symbol}${prompt_path} " } PROMPT_COMMAND="fancygit_prompt_builder" diff --git a/prompt_styles/fancy-double-line.sh b/prompt_styles/fancy-double-line.sh index b72c54d..f0ec135 100644 --- a/prompt_styles/fancy-double-line.sh +++ b/prompt_styles/fancy-double-line.sh @@ -79,7 +79,16 @@ fancygit_prompt_builder() { return fi - PS1="${prompt_user}${prompt_path}${prompt_symbol} " + local venv="" + + if ! [ -z ${VIRTUAL_ENV} ] + then + prompt_user="${user_at_host} \\u@\\h ${user_at_host_end}" + venv="`basename \"$VIRTUAL_ENV\"`" + venv="${bg_light_magenta}${bold}${white}${venv} ${path_end}${s_lightmagenta_bgdarkgray}" + fi + + PS1="${venv}${prompt_user}${prompt_path}${prompt_symbol} " } PROMPT_COMMAND="fancygit_prompt_builder" diff --git a/prompt_styles/human-dark.sh b/prompt_styles/human-dark.sh index 2a3c02f..a684085 100644 --- a/prompt_styles/human-dark.sh +++ b/prompt_styles/human-dark.sh @@ -78,13 +78,19 @@ fancygit_prompt_builder() { local at="${red}at${none}" local in="${red}in${none}" local on="${red}on${none}" + local venvfor="${red}for${none}" # Prompt local user="\u" local host="\h" local where="\W" + local venv="" - PS1="${bold}${user} ${at} ${host} ${in} $where $(fg_branch_name)${bold_none}\n\$ " + if ! [ -z ${VIRTUAL_ENV} ]; then + venv="`basename \"$VIRTUAL_ENV\"` ${venvfor} " + fi + + PS1="${bold}${venv}${user} ${at} ${host} ${in} $where $(fg_branch_name)${bold_none}\n\$ " } PROMPT_COMMAND="fancygit_prompt_builder" diff --git a/prompt_styles/human.sh b/prompt_styles/human.sh index 7ad29b3..c78b9f4 100644 --- a/prompt_styles/human.sh +++ b/prompt_styles/human.sh @@ -80,8 +80,13 @@ fancygit_prompt_builder() { local user="${orange}\u${none}" local host="${light_yellow}\h${none}" local where="${light_green}\w${none}" + local venv="" - PS1="${bold}${user} at ${host} in $where $(fg_branch_name)${bold_none}\n\$ " + if ! [ -z ${VIRTUAL_ENV} ]; then + venv="${light_yellow}`basename \"$VIRTUAL_ENV\"`${none} for " + fi + + PS1="${bold}${venv}${user} at ${host} in $where $(fg_branch_name)${bold_none}\n\$ " } PROMPT_COMMAND="fancygit_prompt_builder" diff --git a/prompt_styles/light-double-line.sh b/prompt_styles/light-double-line.sh index 298273f..f23ea4e 100644 --- a/prompt_styles/light-double-line.sh +++ b/prompt_styles/light-double-line.sh @@ -63,7 +63,7 @@ fancygit_prompt_builder() { prompt_user="${user_at_host}\\u@\\h ${user_at_host_end}" prompt_symbol="\n${user_symbol}\$${user_symbol_end}" - prompt_path="${path}${bold}${white} \\w ${path_end}${s_darkgray}" + prompt_path="${path}${bold}${black} \\w ${path_end}${s_lightgray}" local only_local_branch=$(git branch -a 2> /dev/null | egrep "remotes/origin/${branch_name}" | wc -l) @@ -79,7 +79,16 @@ fancygit_prompt_builder() { return fi - PS1="${prompt_user}${prompt_path}${prompt_symbol} " + local venv="" + + if ! [ -z ${VIRTUAL_ENV} ] + then + prompt_user="${user_at_host} \\u@\\h ${user_at_host_end}" + venv="`basename \"$VIRTUAL_ENV\"`" + venv="${bg_light_gray}${bold}${black}${venv} ${path_end}${s_lightgray_bgwhite}" + fi + + PS1="${venv}${prompt_user}${prompt_path}${prompt_symbol} " } PROMPT_COMMAND="fancygit_prompt_builder" diff --git a/prompt_styles/light.sh b/prompt_styles/light.sh index ec1f714..7c79436 100644 --- a/prompt_styles/light.sh +++ b/prompt_styles/light.sh @@ -79,7 +79,16 @@ fancygit_prompt_builder() { return fi - PS1="${prompt_user}${prompt_symbol}${prompt_path} " + local venv="" + + if ! [ -z ${VIRTUAL_ENV} ] + then + prompt_user="${user_at_host} \\u@\\h ${user_at_host_end}" + venv="`basename \"$VIRTUAL_ENV\"`" + venv="${bg_white}${bold}${black}${venv} ${path_end}${s_white_bglightgray}" + fi + + PS1="${venv}${prompt_user}${prompt_symbol}${prompt_path} " } PROMPT_COMMAND="fancygit_prompt_builder" diff --git a/prompt_styles/simple-double-line.sh b/prompt_styles/simple-double-line.sh index 7be2e46..eadb782 100644 --- a/prompt_styles/simple-double-line.sh +++ b/prompt_styles/simple-double-line.sh @@ -77,13 +77,18 @@ fancygit_prompt_builder() { local at local host local where + local venv="" user="${light_green}\u${none}" at="${none}@${none}" host="${light_green}\h${none}" where="${blue}\w${none}" - PS1="${bold}$user$at$host:$where$(fg_branch_name)${bold_none}\n\$ " + if ! [ -z ${VIRTUAL_ENV} ]; then + venv="(`basename \"$VIRTUAL_ENV\"`) " + fi + + PS1="${bold}${venv}$user$at$host:$where$(fg_branch_name)${bold_none}\n\$ " } PROMPT_COMMAND="fancygit_prompt_builder" diff --git a/prompt_styles/simple.sh b/prompt_styles/simple.sh index 04348c5..f230b00 100644 --- a/prompt_styles/simple.sh +++ b/prompt_styles/simple.sh @@ -77,13 +77,18 @@ fancygit_prompt_builder() { local at local host local where + local venv="" user="${light_green}\u${none}" at="${none}@${none}" host="${light_green}\h${none}" where="${blue}\w${none}" - PS1="${bold}$user$at$host:$where\$$(fg_branch_name)${bold_none} " + if ! [ -z ${VIRTUAL_ENV} ]; then + venv="(`basename \"$VIRTUAL_ENV\"`) " + fi + + PS1="${bold}${venv}$user$at$host:$where\$$(fg_branch_name)${bold_none} " } PROMPT_COMMAND="fancygit_prompt_builder" diff --git a/version.sh b/version.sh index 4a8a086..90ce1e5 100644 --- a/version.sh +++ b/version.sh @@ -3,4 +3,4 @@ # Author: Diogo Alexsander Cavilha # Date: 11.17.2017 -FANCYGIT_VERSION="5.3.0" +FANCYGIT_VERSION="6.0.0"