Dwarves Radio Talk #9: Dotfiles are simply amazing!

Dotfiles use cases and how we make better use of them


  • Dotfiles use cases:
    • Automated installing process
    • environment variables management
  • Don’t push any secret (api key, data source, …) to the codebase. Just share within the project team.
  • If you accidentally push secret to your repo. Here’s the checklist:
    • Delete the repository
    • Revoke & Rotate your key
  • We have sample dotfiles for juniors to easily set up their laptop. https://github.com/dwarvesf/dotfiles#automate-your-development-environment


Some junior engineers requested deep sharing about Dotfiles. So Hieu - our experienced engineer walks them through some information. Let the mentoring begin!

Dotfile? Just a file that has a dot in front of the file name!

Dotfiles are files and folders on Unix-like (ex: Linux, macOS) systems starting with . (dot) that save and control the configuration of applications and shells on your system. To see dotfiles, just run the command ls -a

It already includes default dotfiles (that’s hidden) in the list. If dotfile is in user files, it’s a configuration for users, similarly to configuration for projects. We usually make use of dotfiles to store secret keys and manage Environment Variables (.env file).

What are Environment Variables? As the name suggests, they’re variables in your system that describe your environment.

  • Imagining we have two projects using the same key to send emails (Sendgrid, for example). If they use the same Environment Variable (SENDGRID_API_KEY) to load the Email delivery service, we only need one time to load when opening the Terminal.
  • What if two projects have two different keys? So we need to save Environment Variable (.env file) into each project, then source .env after opening it. The Environment Variable of configuration files will be loaded.

Setup Environment Variables by using dotfiles for a project

  1. Add .env file. Each engineer usually has their own .env. People don’t put .env to their repo because of the security. Someone can clone whatever .env file in the project into doc.env file.
  2. Run the project by:
    • cmd source .env
    • Or use autoenv. Using the tool is pretty cool because it’s able to find and automate loading .env files.
    • or use Makefile
  3. Finally, make run

How about Dotfiles on mobile?

The Environment Variables in mobile are called Xcode config files. When building a project, it reads the variable and stores it in plist. The app will read from plist file while running. Each environment (dev, staging, production) has its own config file. So we just need to share this file while a new teammate joins.


  • How to manage Environment Variables in CI/CD or production?

    It will be stored in the server and managed by the person who sets up the project or CI/CD.

  • If we accidentally push the secret key to git, how to handle this case 😢?

    Delete the repo! Or change the key if it’s faster. Overall, it’s very complicated and sensitive, be careful!

Share this post

Subscribe for “The Next Bytes” where Han & the crew draft up our observation in the industry.

We’d love to work with you.

Drop us a message if you need any helps from the Dwarves

Let’s build with us