Skip to content

Instantly share code, notes, and snippets.

@yrevar
Last active March 17, 2016 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yrevar/0a8b9981025e340395f4 to your computer and use it in GitHub Desktop.
Save yrevar/0a8b9981025e340395f4 to your computer and use it in GitHub Desktop.
export PATH=$PATH:/$HOME/bin
if [ -z ${DISPLAY} ]
then
export DISPLAY=:0.0
fi
# Terminal history settings
export HISTCONTROL=ignoredups:erasedups # no duplicate entries
export HISTSIZE=1000000 # big big history
export HISTFILESIZE=1000000 # big big history
shopt -s histappend # append to history, don't overwrite it
# Homebrew
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
# Better command history search. Just copying won't work, be sure to read http://www.macworld.com/article/1146015/os-x/termhistory.html
bind '"^[[A":history-search-backward'
bind '"^[[B":history-search-forward'
alias setJdk6='export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)'
alias setJdk7='export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)'
alias setJdk8='export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)'
alias prompt_full='export PS1="\u@\h\w $ "'
export PS1="\u @ \W $ "
# pip should only run if there is a virtualenv currently activated
export PIP_REQUIRE_VIRTUALENV=true
gpip(){
PIP_REQUIRE_VIRTUALENV="" pip "$@"
}
# you can set your preferred virtual environment directort here
PY_VIRTUALENV_HOME="$HOME/virtualenvs/"
pyenv_list(){
ls $PY_VIRTUALENV_HOME
}
pyenv_activate(){
export PY_VIRTUALENV_PATH=$PY_VIRTUALENV_HOME/"$@"
source $PY_VIRTUALENV_PATH/bin/activate
}
# Working with Matplotlib in Virtual environments: http://matplotlib.org/faq/virtualenv_faq.html
function frameworkpython {
if [[ ! -z "$PY_VIRTUALENV_PATH" ]]; then
PYTHONHOME=$PY_VIRTUALENV_PATH /usr/local/bin/python "$@"
else
/usr/local/bin/python "$@"
fi
}
@yrevar
Copy link
Author

yrevar commented Mar 3, 2016

Note: This article assumes you have installed virtualenv (pip install virtualenv).

Usage:

# Create virtual environment. (To give access to global site-packages, add switch  --system-site-packages, however 
# this breaks the isolation between the virtual environment and the system)
virtualenv $HOME/virtualenvs 

# List virtual environments
$ pyenv_list 

# Activate virtual environment
$ pyenv_activate <name>

# Deactivate virtual environment
$ deactivate

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