Direnv: Plans for aliases?

Created on 26 Mar 2014  路  4Comments  路  Source: direnv/direnv

It would be handy if I can use the .envrc to setup project specific aliases as well:

alias deploy="bundle exec rspec && gps origin && BRANCH=master cap production deploy"

This doesn't work.

Most helpful comment

The .envrc is currently evaluated in a bash sub-shell and the environment variables are exported to direnv. That allows us to have zsh and fish compatibility (and make sure you don't get halfly evaluated environments in cases where there is an issue).

Aliases would be great but I don't really know if they're doable in a cross-shell way. The current workaround is to add a directory in your path and define your aliases as shell scripts.

.envrc

PATH_add bin

bin/deploy

#!/bin/sh
bundle exec rsepc && gps origin && BRANCH=master cap production deploy

All 4 comments

The .envrc is currently evaluated in a bash sub-shell and the environment variables are exported to direnv. That allows us to have zsh and fish compatibility (and make sure you don't get halfly evaluated environments in cases where there is an issue).

Aliases would be great but I don't really know if they're doable in a cross-shell way. The current workaround is to add a directory in your path and define your aliases as shell scripts.

.envrc

PATH_add bin

bin/deploy

#!/bin/sh
bundle exec rsepc && gps origin && BRANCH=master cap production deploy

Duplicate of #73

@zimbatm - Strange question resurrecting the dead here...

In this directory, if I wanted to call up this _alias_ of the deploy command at a terminal by typing $ dep[TAB]

it wouldn't work because I can't tab out bash scripts without being in the directory and doing something like $ ./dep[TAB]

Any thoughts on working around this?

yeah it's best to open new issues.

try adding PATH_add . to the .envrc. Once the project root is in the path the script will be found by bash.

Was this page helpful?
0 / 5 - 0 ratings