Unix setup

Aliases and .env setup
code snippets
jupyter
python

March 4, 2020

virtual environment setup

Upgrade pip.

python3 -m pip install --upgrade pip

Create a base folder to store the virtual environments in.

mkdir ~/.venv

Create a new virtual environment.

python3 -m venv ~/.venv/venv

Activate the virtual environment.

source ~/.venv/venv/bin/activate

Install ipykernel.

python3 -m pip install ipykernel

Add the new kernel.

ipython kernel install --name=venv #--user

TL;DR

python3 -m pip install --upgrade pip
mkdir ~/.venv
python3 -m venv ~/.venv/venv
source ~/.venv/venv/bin/activate
python3 -m pip install ipykernel
ipython kernel install --name=venv #--user

alias setup

Add the following aliases to your .bashrc or .zshrc file:

Activate your virtual environment and start jupyter notebook.

alias jn='source ~/.venv/venv/bin/activate && jupyter notebook'

Activate your virtual environment.

alias letsgo='source ~/.venv/venv/bin/activate'

Activate any of your virtual environments.

function act { source ~/.virtualenvs/"$1"/bin/activate }
> act venv

The standard zsh shell that comes with macOS doesn’t print the current active virtual environment. Add the following to ~/.zshrc to enable showing the virtual environment.

export VIRTUAL_ENV_DISABLE_PROMPT=

Activate the virtual environment by default.

if [[ "$VIRTUAL_ENV" != "/Users/fabian/.venv/venv" ]]; then source ~/.venv/venv/bin/activate; fi

Set default directory to ~/Code.

if [[ $PWD == $HOME ]]; then cd /Users/fabian/Code; fi

TL;DR

alias jn='source ~/.venv/venv/bin/activate && jupyter notebook'
alias letsgo='source ~/.venv/venv/bin/activate'
alias typora="open -a typora"
alias cm="git add . && git commit -am "Update" && git push"

function act { source ~/.venv/"$1"/bin/activate }

export VIRTUAL_ENV_DISABLE_PROMPT=

if [[ "$VIRTUAL_ENV" != "/Users/fabian/.venv/venv" ]]; then source ~/.venv/venv/bin/activate; fi

if [[ $PWD == $HOME ]]; then cd /Users/fabian/Code; fi