Created
August 15, 2016 03:20
-
-
Save mludvig/a879e707fecb3dec4fb347eedd80a350 to your computer and use it in GitHub Desktop.
Initialise Python VirtualEnv and show it's name in $PS1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# virtualenv init.sh - Initialise Python VirtualEnv and show it in $PS1 | |
# By Michael Ludvig <mludvig@logix.net.nz> | |
# Usage | |
# 1) copy this file as 'init.sh' to your 'virtualenv' project's folder | |
# 2) run it, e.g. ~/whatever/init.sh (where 'whatever' is the project) | |
if [ -z "${_MY_DIR}" ]; then | |
export _MY_DIR=$(dirname $0) | |
test -z "${_MY_DIR}" && _MY_DIR=$(dirname $(which $0)) | |
exec bash --rcfile ${_MY_DIR}/init.sh | |
else | |
source ${_MY_DIR}/bin/activate | |
_VIRTENV=$(basename ${VIRTUAL_ENV}) | |
echo -e "\e[33;1mVirtualenv ${_VIRTENV} activated. Use ^D to exit...\e[0m" | |
export PS1="\u@\h \[\e[37;1m\]\w\[\e[0m\] \[\e[34m\]{${_VIRTENV}}\[\e[0m\]\$(__git_ps1 ' \[\e[35m\](%s)\[\e[0m\]') \$ " | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment