Giter VIP home page Giter VIP logo

projectile-direnv's Introduction

projectile-direnv.el

Have Emacs set environment variables defined in a project’s .envrc.

Motivation

When working at the terminal, I use direnv to export environment variables that alter the behavior of the 12 factor applications I write. direnv automatically exports the variables to the environment when you cd into a directory containing a .envrc file.

When launching a GUI instance of Emacs (not from the terminal), direnv never gets the chance to export your environment variables, however.

This package contains a command projectile-direnv-export-variables which will look for a .envrc file in the projectile-project-root.

It will then parse the .envrc file for exports and call setenv in the Emacs environment. This is useful, for instance, when launching processes from within Emacs (e.g. REPLs) that depend on the values in these variables.

Installation

This package is available on MELPA as projectile-direnv

https://melpa.org/packages/projectile-direnv-badge.svg

Dependencies

Usage

The easiest way to use this package is to invoke projectile-direnv-export-variables from a hook:

(add-hook 'projectile-mode-hook 'projectile-direnv-export-variables)

Cautionary Note

You should only do this if you work on one project with a .envrc file at a time. This is because Emacs’ environment is a global one, and projectile mode is per-buffer. It is easily conceivable to visit a file in one project and load envvars whose names clash with those in another project. This will cause a last-project-wins scenario that could lead to confusion and frustrated debugging.

There are two ways to address this concern.

  1. Explicitly invoke the command (instead of using a hook)
  2. Name your environment variables uniquely with a project prefix

Limitations / Known Issues

  • This package doesn’t yet handle variable unloading
  • Ideally, the user should be prompted to allow a particular .envrc just as direnv does (and Emacs does when loading from .dir-locals.el)

License (GPL v3)

Copyright (C) 2016 Free Software Foundation, Inc.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

projectile-direnv's People

Contributors

shanexu avatar syohex avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.