Bash: Virtualenv stuff.

This commit is contained in:
Artem Sapegin 2013-03-14 23:21:32 +04:00
parent ec8b4ace1c
commit e16b0b1397
2 changed files with 12 additions and 1 deletions

View File

@ -99,6 +99,10 @@ alias gw="grunt watch --debug"
alias gs="grunt connect watch --debug"
gi() { grunt-init $@; }
# Virtualenv
alias venv='test -d ENV && source ./ENV/bin/activate || echo "No Virtualenv in the current folder."'
alias venv-init='test -d ENV && echo "Virtualenv already exists." || virtualenv --no-site-packages ENV; venv'
# Magic Project Opener
function proj { cd "$("$HOME/dotfiles/bin/opener.py" "$HOME/Dropbox/Projects" $1 -w project $2)"; }
function repo { cd "$("$HOME/dotfiles/bin/opener.py" "$HOME/Dropbox/Projects" $1 -w repo $2)"; }

View File

@ -20,6 +20,7 @@ esac
prompt_symbol=""
prompt_clean_symbol="☀ "
prompt_dirty_symbol="☂ "
prompt_venv_symbol="☁ "
function prompt_command() {
# Local or SSH session?
@ -48,6 +49,12 @@ function prompt_command() {
fi
fi
# Virtualenv
local venv_prompt=
if [ -n "$VIRTUAL_ENV" ]; then
venv_prompt=" $BLUE$prompt_venv_symbol$(basename $VIRTUAL_ENV)$NOCOLOR"
fi
# Only show username if not default
local user_prompt=
[ "$USER" != "$local_username" ] && user_prompt="$user_color$USER$NOCOLOR"
@ -61,7 +68,7 @@ function prompt_command() {
[ -n "$user_prompt" ] || [ -n "$host_prompt" ] && login_delimiter=":"
# Format prompt
first_line="$user_prompt$host_prompt$login_delimiter$WHITE\w$NOCOLOR$git_prompt"
first_line="$user_prompt$host_prompt$login_delimiter$WHITE\w$NOCOLOR$git_prompt$venv_prompt"
# Text (commands) inside \[...\] does not impact line length calculation which fixes stange bug when looking through the history
# $? is a status of last command, should be processed every time prompt prints
second_line="\`if [ \$? = 0 ]; then echo \[\$CYAN\]; else echo \[\$RED\]; fi\`\$prompt_symbol\[\$NOCOLOR\] "