Skip to content

Commit 665c211

Browse files
author
Giovanni Intini
committed
Added python virtualenv and rvm support.
1 parent 8c4f42d commit 665c211

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

bash-powerline.sh

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ __powerline() {
1010
readonly GIT_BRANCH_CHANGED_SYMBOL='+'
1111
readonly GIT_NEED_PUSH_SYMBOL=''
1212
readonly GIT_NEED_PULL_SYMBOL=''
13+
readonly PYTHON_SYMBOL='ƨ'
14+
readonly RUBY_SYMBOL=''
1315

1416
# Solarized colorscheme
1517
readonly FG_BASE03="\[$(tput setaf 8)\]"
@@ -65,7 +67,7 @@ __powerline() {
6567
readonly PS_SYMBOL=$PS_SYMBOL_OTHER
6668
esac
6769

68-
__git_info() {
70+
__git_info() {
6971
[ -x "$(which git)" ] || return # git not found
7072

7173
local git_eng="env LANG=C git" # force git output in English to make our work easier
@@ -89,9 +91,26 @@ __powerline() {
8991
printf " $GIT_BRANCH_SYMBOL$branch$marks "
9092
}
9193

94+
__virtualenv() {
95+
if [ -z "${VIRTUAL_ENV}" ] ; then
96+
return
97+
else
98+
local virtualenv="$(basename $VIRTUAL_ENV)"
99+
printf " $PYTHON_SYMBOL $virtualenv "
100+
fi
101+
}
102+
103+
__rvm() {
104+
if [ -z "${RUBY_VERSION}" ] ; then
105+
return
106+
else
107+
printf " $RUBY_VERSION "
108+
fi
109+
}
110+
92111
ps1() {
93112
# Check the exit code of the previous command and display different
94-
# colors in the prompt accordingly.
113+
# colors in the prompt accordingly.
95114
if [ $? -eq 0 ]; then
96115
local BG_EXIT="$BG_GREEN"
97116
else
@@ -100,6 +119,8 @@ __powerline() {
100119

101120
PS1="$BG_BASE1$FG_BASE3 \w $RESET"
102121
PS1+="$BG_BLUE$FG_BASE3$(__git_info)$RESET"
122+
PS1+="$BG_VIOLET$FG_BASE3$(__virtualenv)$RESET"
123+
PS1+="$BG_ORANGE$FG_BASE3$(__rvm)$RESET"
103124
PS1+="$BG_EXIT$FG_BASE3 $PS_SYMBOL $RESET "
104125
}
105126

0 commit comments

Comments
 (0)