Tech BlogBrand Name

Install direnv on Ubuntu 18.04 in 1 min

At Will & Skill we care deeply about using the right tools to optimize our workflow. If we can shave off a few seconds here and there we can save a lot of time in the long run.

direnv is a small but nifty tool that optimizes the task of switching to the right virtualenv

1. Install direnv

sudo apt-get update
sudo apt-get install direnv

2. Add the snippet below in Your .bashrc/.zshrc

show_virtual_env() {
  if [ -n "$VIRTUAL_ENV" ]; then
    echo "($(basename $VIRTUAL_ENV))"


# direnv
eval "$(direnv hook bash)"

3. Add .direnvrc to your home folder

Copy this snippet to the .direnv that You just created

layout_virtualenv() {
  local venv_path="$1"
  source ${venv_path}/bin/activate

4. Add .envrc in your project folder for instance in /home/faisal/myproject and copy the snippet below into the file

layout virtualenv ~/myproject/myproject-env

That's it! Happy coding.