Skip to content

Repository files navigation

dotfiles

🚀 Overview

Your dotfiles are how you personalize your system. These are mine.

Maintaining dotfiles for your computer is crucial for several reasons. Firstly, it ensures consistency across different machines, allowing you to replicate your preferred settings, shortcuts, and configurations effortlessly. This consistency saves time and frustration when transitioning between workstations or setting up a new system. Secondly, dotfiles serve as a personal backup of your customized environment. By version-controlling them with tools like Git, you not only safeguard against accidental changes but also enable easy restoration in case of system crashes or upgrades.

🌴 Setup

To set up the dotfiles run the appropriate snippet in the terminal.

💻 MacOS MacOS

  • Configuration snippet of the Apple Silicon MacOS environment for client macnine:
bash -c "$(curl -fsLS https://raw.githubusercontent.com/pragmaticivan/dotfiles/main/setup.sh)"

🖥️ Ubuntu Ubuntu

  • Configuration snippet of the Ubuntu environment for both client and server machine:
bash -c "$(wget -qO - https://raw.githubusercontent.com/pragmaticivan/dotfiles/main/setup.sh)"

Minimal setup

The following is a minimal setup command to install chezmoi and my dotfiles from the github repository on a new empty machine:

sh -c "$(curl -fsLS get.chezmoi.io)" -- init pragmaticivan --apply

🛠️ Update & Test 🧪

Updating and testing the dotfiles follows chezmoi's daily operations. To verify that the updated scripts work correctly, run the scripts on the actual local machine and on the docker container.

🐳 Test on Docker Container

Test the executation of the setup scripts on Ubuntu in its initial state. The following command will launch the test environment using Docker 🐳.

make docker-dev

# docker run -it -v "$(pwd):/home/$(whoami)/.local/share/chezmoi" dotfiles /bin/bash --login
# pragmaticivan@6f97d279cb51:~$

Run the chezmoi init --apply command to verify that the system is set up correctly.

pragmaticivan@5f93d270cb51:~$ chezmoi init --apply

🦇 Unit Test with Bats

Test the shellscript for setup with Bash Automated Testing System (bats). The scripts for the unit test can be found under ./tests directory.

🔀 macOS install profiles (personal vs restricted)

On macOS, Homebrew apps are installed from a templated Brewfile that respects a profile:

  • personal: full set of apps (default)
  • restricted: minimal set for locked-down environments

The profile is stored per machine in ~/.config/chezmoi/chezmoi.toml, captured at chezmoi init. Set it once:

DOTFILES_PROFILE=restricted chezmoi init --apply   # or answer the "Install profile" prompt

Every later chezmoi apply keeps that profile. To check: chezmoi data | jq .profile.

The env var also works as a one-off override on any command:

DOTFILES_PROFILE=restricted chezmoi apply

Be aware that a one-off override leaves the affected files differing from the stored target state, so the next plain chezmoi apply reverts them. Prefer changing the stored value (re-run chezmoi init, or edit profile in ~/.config/chezmoi/chezmoi.toml).

Profile-aware targets are Brewfile (personal-only casks: extra browsers, chat apps, media, games) and .gitconfig (commit email). Note that brew bundle never uninstalls, so switching to restricted stops installing personal apps but does not remove ones already present.

👏 Acknowledgements

Inspiration and code was taken from many sources, including:

📝 License

The code is available under the MIT license.

About

pragmaticivan's personal configurations

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages