Configuring vim-dadbod-ui with direnv
I previously wrote about how I work with databases locally using vim-dadbod and vim-dadbod-ui.
In that post, I showed how to use the :DBUIAddconnection command to add a new database connection - but you can also do it with environment variables.
For example, this will create a new database called db:
export DB_UI_DB='mysql://db:[email protected]:59002/db'
Using direnv
This works well with direnv - a tool for loading and unloading environment variables depending on the current directory, that I often use with Nix.
I can add this to an .envrc file, direnv will load it and its environment variables, and make them available to vim-dadbod-ui.
And if you need more databases, just add more environment variables with the DB_UI_ prefix.