Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Powerline for Bash in pure Bash script.
* Git branch: display "+" symbol when current branch is changed but uncommited
* Git branch: display "⇡" symbol and the difference in the number of commits when the current branch is ahead of remote (see screenshot)
* Git branch: display "⇣" symbol and the difference in the number of commits when the current branch is behind of remote (see screenshot)
* Python virtualenv: display current virtual environment
* Platform-dependent prompt symbol for OS X and Linux (see screenshots)
* Color code for the previously failed command
* Fast execution (no noticable delay)
Expand Down
19 changes: 18 additions & 1 deletion bash-powerline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ __powerline() {
printf " $GIT_BRANCH_SYMBOL$branch$marks "
}

__virtualenv() {
# Copied from Python virtualenv's activate.sh script.
# https://github.com/pypa/virtualenv/blob/a9b4e673559a5beb24bac1a8fb81446dd84ec6ed/virtualenv_embedded/activate.sh#L62
# License: MIT
if [ "x$VIRTUAL_ENV" != "x" ]; then
if [ "`basename \"$VIRTUAL_ENV\"`" == "__" ]; then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
printf "[`basename \`dirname \"$VIRTUAL_ENV\"\``]"
else
printf "(`basename \"$VIRTUAL_ENV\"`)"
fi
fi
}

ps1() {
# Check the exit code of the previous command and display different
# colors in the prompt accordingly.
Expand All @@ -98,7 +113,9 @@ __powerline() {
local BG_EXIT="$BG_RED"
fi

PS1="$BG_BASE1$FG_BASE3 \w $RESET"
PS1=""
PS1+="$BG_BASE0$FG_BASE3$(__virtualenv)$RESET"
PS1+="$BG_BASE1$FG_BASE3 \w $RESET"
PS1+="$BG_BLUE$FG_BASE3$(__git_info)$RESET"
PS1+="$BG_EXIT$FG_BASE3 $PS_SYMBOL $RESET "
}
Expand Down