Skip to content

Commit

Permalink
Add support for python virtualenv (#12)
Browse files Browse the repository at this point in the history
* Add support for python virtualenv

* Fix missing $ when using virtualenv color variables

* Add Python Virtualenv section to the TOC

* Add an env variable to control the python virtualenv surrounding parens color

* Avoid an extra white space on the rprompt when the virtualenv is empty
  • Loading branch information
fgandellini authored and mgee committed May 25, 2017
1 parent abd601a commit 0e8f8f0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ For a fish compatible version of this theme have a look at [slimfish](https://gi
- [User and Host Info](#user-and-host-info)
- [AWS Profile Info](#aws-profile-info)
- [Auto Correction](#auto-correction)
- [Python Virtualenv](#python-virtualenv)
- [Git Information](#git-information)
- [Gitline](#gitline)
- [Example](#example)
Expand Down Expand Up @@ -183,6 +184,20 @@ Defines the color of the misspelled string for which is correction is proposed.

Defines the color of the proposed correction of a misspelled string. Default is `green`.

### Python Virtualenv

##### `SLIMLINE_DISPLAY_VIRTUALENV`

Defines whether active python virtualenv shall be displayed. Default is `1`.

##### `SLIMLINE_VIRTUALENV_COLOR`

Defines the color of the virtualenv name. Default is `cyan`.

##### `SLIMLINE_VIRTUALENV_PARENS_COLOR`

Defines the color of the parens surrounding the virtualenv name. Default is `white`.

### Git Information

##### `SLIMLINE_ENABLE_GIT`
Expand Down
14 changes: 14 additions & 0 deletions slimline.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ prompt_slimline_cwd() {
echo "%F{${cwd_color}}%3~%f "
}

prompt_slimline_virtualenv() {
local parens_color="${SLIMLINE_VIRTUALENV_PARENS_COLOR:-white}"
local virtualenv_color="${SLIMLINE_VIRTUALENV_COLOR:-cyan}"
[ $VIRTUAL_ENV ] && echo "%F{$parens_color}(%f%F{$virtualenv_color}`basename $VIRTUAL_ENV`%f%F{$parens_color})%f"
}

prompt_slimline_set_prompt() {
local symbol_color=${1:-${SLIMLINE_PROMPT_SYMBOL_COLOR_WORKING:-red}}

Expand Down Expand Up @@ -106,6 +112,14 @@ prompt_slimline_set_rprompt() {
if [[ -n "${_prompt_slimline_git_output:-}" ]]; then
RPROMPT+="${RPROMPT:+ }${_prompt_slimline_git_output}"
fi

# add virtualenv (if active and not empty)
if (( ${SLIMLINE_DISPLAY_VIRTUALENV:-1} )); then
local virtual_env="$(prompt_slimline_virtualenv)"
if [[ -n "${virtual_env}" ]]; then
RPROMPT+="${RPROMPT:+ }${virtual_env}"
fi
fi
}

prompt_slimline_set_sprompt() {
Expand Down

0 comments on commit 0e8f8f0

Please sign in to comment.