OnWorks favicon

direnv - Online in the Cloud

Run direnv in OnWorks free hosting provider over Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator

This is the command direnv that can be run in the OnWorks free hosting provider using one of our multiple free online workstations such as Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator



direnv - unclutter your .profile


direnv command ...


direnv is an environment variable manager for your shell. It knows how to hook into bash,
zsh and fish shell to load or unload environment variables depending on your current
directory. This allows you to have project-specific environment variables and not clutter
the "~/.profile" file.

Before each prompt it checks for the existence of an ".envrc" file in the current and
parent directories. If the file exists, it is loaded into a bash sub-shell and all
exported variables are then captured by direnv and then made available to your current

Because direnv is compiled into a single static executable it is fast enough to be
unnoticeable on each prompt. It is also language agnostic and can be used to build
solutions similar to rbenv, pyenv, phpenv, ...


$ cd ~/my_project
$ echo ${FOO-nope}
$ echo export FOO=foo > .envrc
.envrc is not allowed
$ direnv allow .
direnv: reloading
direnv: loading .envrc
direnv export: +FOO
$ echo ${FOO-nope}
$ cd ..
direnv: unloading
direnv export: ~PATH
$ echo ${FOO-nope}


For direnv to work properly it needs to be hooked into the shell. Each shell has it's own
extension mechanism:

Add the following line at the end of your "~/.bashrc" file:

eval "$(direnv hook bash)"

Make sure it appears even after rvm, git-prompt and other shell extensions that manipulate
your prompt.

Add the following line at the end of your "~/.zshrc" file:

eval "$(direnv hook zsh)"

Add the following line at the end of your "~/.config/fish/config.fish" file:

eval (direnv hook fish)

Add the following line at the end of your "~/.cshrc" file:

eval `direnv hook tcsh`


In some target folder, create an ".envrc" file and add some export(1) directives in it.

On the next prompt you will notice that direnv complains about the ".envrc" being blocked.
This is the security mechanism to avoid loading new files automatically. Otherwise any git
repo that you pull, or tar archive that you unpack, would be able to wipe your hard drive
once you cd into it.

So here we are pretty sure that it won't do anything bad. Type direnv allow . and watch
direnv loading your new environment. Note that direnv edit . is a handy shortcut that open
the file in your $EDITOR and automatically allows it if the file's modification time has

Now that the environment is loaded you can notice that once you cd out of the directory it
automatically gets unloaded. If you cd back into it it's loaded again. That's the base of
the mechanism that allows you to build cool things.

Exporting variables by hand is a bit repetitive so direnv provides a set of utility
functions that are made available in the context of the ".envrc" file. Check the direnv-
stdlib(1) man page for more details. You can also define your own extensions inside a
"~/.direnvrc" file.

Hopefully this is enough to get you started.


Bug reports, contributions and forks are welcome.

All bugs or other forms of discussion happen on ⟨http://github.com/direnv/direnv/issues

There is also a wiki available where you can share your usage patterns or other tips and
tricks ⟨https://github.com/direnv/direnv/wiki⟩

Or drop by on the #direnv channel on FreeNode ⟨irc://#direnv@FreeNode⟩ to have a chat.


Copyright (C) 2014 zimbatm and contributors under the MIT licence.

Use direnv online using onworks.net services

Free Servers & Workstations

Download Windows & Linux apps

  • 1
    TurkDevOps a?k kaynak yaz?l?m
    geli?tirici topluluklar? DevTurks-Team
    Taraf?ndan desteklenmektedir..
    Download turkdevops
  • 2
    Wine is an Open Source implementation
    of the Windows API on top of X and Unix.
    Wine provides both a development toolkit
    for porting Windows sources to Unix and...
    Download Wine
  • 3
    LAME (Lame Aint an MP3 Encoder)
    LAME (Lame Aint an MP3 Encoder)
    LAME is an educational tool to be used
    for learning about MP3 encoding. The
    goal of the LAME project is to improve
    the psycho acoustics, quality and speed
    of MP...
    Download LAME (Lame Aint an MP3 Encoder)
  • 4
    A set of Python extension modules that
    wrap the cross-platform GUI classes from
    wxWidgets.. Audience: Developers. User
    interface: X Window System (X11), Win32 ...
    Download wxPython
  • 5
    This is the Total War pack file manager
    project, starting from version 1.7. A
    short introduction into Warscape
    modding: ...
    Download packfilemanager
  • 6
    A network traffic tool for measuring
    TCP and UDP performance with metrics
    around both throughput and latency. The
    goals include maintaining an active
    iperf cod...
    Download IPerf2
  • 7
    fre:ac - free audio converter
    fre:ac - free audio converter
    fre:ac is a free audio converter and CD
    ripper for various formats and encoders.
    It features MP3, MP4/M4A, WMA, Ogg
    Vorbis, FLAC, AAC, and Bonk format
    support, ...
    Download fre:ac - free audio converter
  • More »

Linux commands