direnv

.envrcに環境変数を設定する

direnvをインストールする

$ brew install direnv

Updating Homebrew...

==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
gptfdisk pijul
==> Updated Formulae
abcde grpc puzzles
angle-grinder gtk-vnc quicktype
angular-cli gutenberg rabbitmq
awscli harfbuzz redis
cargo-completion hashcat ripgrep
cassandra kerl rust
chronograf knot-resolver sceptre
composer kotlin shfmt
cryptol libpst shibboleth-sp
csvprintf libxkbcommon skaffold
cython liquigraph snakemake
dartsim logtalk taskell
dbus macvim teleport
dcos-cli mariadb@10.0 tmux-xpanes
django-completion mercurial todolist
dxpy mkdocs tox
emscripten node trafficserver
erlang@20 node-build uhd
faas-cli ocrmypdf vcftools
firebase-cli openshift-cli webpack
flow paket wireguard-tools
fluent-bit passenger wxmac
gammaray percona-server-mongodb xml-security-c
git-lfs phpunit xtensor
go-jira pilosa yarn
go-statik presto youtube-dl
goenv proselint zebra

Error: Could not link:
/usr/local/share/man/man1/brew.1

Please delete these paths and run `brew update`.
Error: Could not link:
/usr/local/share/doc/homebrew

Please delete these paths and run `brew update`.
==> Downloading https://homebrew.bintray.com/bottles/direnv-2.17.0.sierra.bottle
######################################################################## 100.0%
==> Pouring direnv-2.17.0.sierra.bottle.tar.gz
🍺 /usr/local/Cellar/direnv/2.17.0: 9 files, 5.4MB

.bashrcをエディタで開く

open ~/.bashrc

以下を追記する

eval "$(direnv hook bash)"

.envrcに環境変数を設定する


.envrc

export APIKEY=<APIKEY>

export AUTHDOMAIN=<AUTHDOMAIN>
export DATABASEURL=<DATABASEURL>
export PROJECTID=<PROJECTID>
export STORAGEBUCKET=<STORAGEBUCKET>
export MESSAGINGSENDERID=<MESSAGINGSENDERID>

direnv: loading .envrc

direnv: export +APIKEY +AUTHDOMAIN +DATABASEURL +MESSAGINGSENDERID +PROJECTID +STORAGEBUCKET

direnv: unloading

direnv: error .envrc is blocked. Run `direnv allow` to approve its content.

$ direnv allow