Skip to content

Commit

Permalink
Add Python virtual environment support
Browse files Browse the repository at this point in the history
- Add human-dark mode to the help text.
- Fix light-double-line style.

resolves #28
  • Loading branch information
diogocavilha committed Jun 20, 2019
1 parent 98d6fbe commit 5125fd5
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 2 additions & 0 deletions config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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}"
Expand Down
1 change: 1 addition & 0 deletions help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 10 additions & 1 deletion prompt_styles/dark-double-line.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
11 changes: 10 additions & 1 deletion prompt_styles/dark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
11 changes: 10 additions & 1 deletion prompt_styles/default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
11 changes: 10 additions & 1 deletion prompt_styles/fancy-double-line.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
8 changes: 7 additions & 1 deletion prompt_styles/human-dark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 6 additions & 1 deletion prompt_styles/human.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 11 additions & 2 deletions prompt_styles/light-double-line.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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"
11 changes: 10 additions & 1 deletion prompt_styles/light.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 6 additions & 1 deletion prompt_styles/simple-double-line.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 6 additions & 1 deletion prompt_styles/simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 11.17.2017

FANCYGIT_VERSION="5.3.0"
FANCYGIT_VERSION="6.0.0"

0 comments on commit 5125fd5

Please sign in to comment.