Skip to content

Instantly share code, notes, and snippets.

@staypufd
Last active May 16, 2017 17:29
Show Gist options
  • Save staypufd/0dea840c972383162be5810e15b3d53e to your computer and use it in GitHub Desktop.
Save staypufd/0dea840c972383162be5810e15b3d53e to your computer and use it in GitHub Desktop.
.bashrc that has config for virtual environments to be required and a nice little script 'eve' that tries to activate python virtualenv and if not prints a informative error
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.7
MYSQL=/usr/local/mysql/bin
MYBIN=~/bin
export PATH=$PATH:$MYBIN
export PATH=$PATH:$MYSQL
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
###########################
#
# Python Settings
#
###########################
# Python VirutalEnv Setup
# https://hackercodex.com/guide/python-development-environment-on-mac-osx/
#
# Override requirement for a virtualenv to be set for pip
# (see ~/Library/Application\ Support/pip/pip.conf)
# (for upgrading system ones and other tools that aren't in a virtualenv)
#
# Example:
# gpip install --upgrade pip setuptools wheel virtualenv
#
gpip(){
PIP_REQUIRE_VIRTUALENV="" pip "$@"
}
pve() {
# printf "In eve command\n\n"
# dir_name=`basename $PWD`
source bin/activate 2>/dev/null
# Check to see if command succeeded.
if [ "$?" = "0" ]; then
printf "\n${GREEN}Enjoy working on $a${NC}\n\n\n"
elif [ $? = 127 ]; then
printf "\n${RED}You are not in a python virtual environment directory.${NC}\n\n"
else
printf "\n${RED}You are not in a python virtual environment directory.${NC}\n\n"
fi
}
dpve() {
deactivate 2>/dev/null
# printf "Status is: "$?
# Check to see if command succeeded.
if [ "$?" = "0" ]; then
printf "\n${GREEN} Goodbye! ${NC}\n\n"
elif [ "$?" = "127" ]; then
printf "\n${RED}Python Virtual Environment not currently active.${NC}\n\n"
else
printf "\n${RED}Python Virtual Environment not currently active.${NC}\n\n"
fi
}
##############################################
# ANSI COLOR CODES
#
#
# Black 0;30 Dark Gray 1;30
# Red 0;31 Light Red 1;31
# Green 0;32 Light Green 1;32
# Brown/Orange 0;33 Yellow 1;33
# Blue 0;34 Light Blue 1;34
# Purple 0;35 Light Purple 1;35
# Cyan 0;36 Light Cyan 1;36
# Light Gray 0;37 White 1;37
#
#
##############################################
@staypufd
Copy link
Author

staypufd commented May 16, 2017

Docs

The eve function is run by typing eve on command line. If you are in a python virtual environment directory it will activate it. If you are not, then it will give you a nice error message.

The dpve function is run by typing dpve on the command line. If you are in a python virtual environment directory it will deactivate it. If you are not, then it will give you a nice error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment