Dotfiles management
They are many solutions to manage dotfiles. I choose dotbot as I found its architecture smart and its usage very ergonomic
1. Chez moi
Installation
scoop install chezmoi Configuration
Start using chezmoi on your current machine
Assuming that you have already installed chezmoi, initialize chezmoi with:
chezmoi init This will create a new git local repository in ~/.local/share/chezmoi where chezmoi will store its source state. By default, chezmoi only modifies files in the working copy.
Manage your first file with chezmoi:
chezmoi add ~/.bashrc This will copy ~/.bashrc to ~/.local/share/chezmoi/dot_bashrc.
Edit the source state:
chezmoi edit ~/.bashrc This will open ~/.local/share/chezmoi/dot_bashrc in your $EDITOR. Make some changes and save the file.
Hint
You don’t have to use chezmoi edit to edit your dotfiles. See this FAQ entry for more details.
See what changes chezmoi would make:
chezmoi diff Apply the changes:
chezmoi -v apply All chezmoi commands accept the -v (verbose) flag to print out exactly what changes they will make to the file system, and the -n (dry run) flag to not make any actual changes. The combination -n -v is very useful if you want to see exactly what changes would be made.
Next, open a shell in the source directory, to commit your changes:
chezmoi cd
git add .
git commit -m "initial commit" Create a new repository on GitHub called dotfiles and then push your repo:
git remote add origin https://github.com/$GITHUB_USERNAME/dotfiles.git $ git branch -M main $ git push -u origin main Hint
chezmoi can be configured to automatically add, commit, and push changes to your repo.
chezmoi can also be used with GitLab, or BitBucket, Source Hut, or any other git hosting service.
Finally, exit the shell in the source directory to return to where you were:
exit 2. Dotbot (is what I’m using)
- Install dotbot requirement (cfr documentation)
Initialization
cd ~/.dotfiles # replace with the path to your dotfiles
git init` # initialize repository if needed
git submodule add https://github.com/anishathalye/dotbot
git config -f .gitmodules submodule.dotbot.ignore dirty # ignore dirty commits in the submodule
cp dotbot/tools/git-submodule/install .
touch install.conf.yaml Include existing configurations
- Copy the folder or files to dotbot directory and remove them in their initial location (because dotbot will create symlink for all those files and folders)
- Edit the install.conf.yaml file to precise the location and name on the PC (location where symlink will be created) and the location on the Github repos
defaults:
link:
create: true
relink: true
- clean: ["~"]
- link:
~/.dotfiles: ""
~/.config/mpv:
~/.config/nvim:
~/AppData/Roaming/nushell/config.nu: nushell/config.nu
~/.config/nushell/config.nu: nushell/config.nu
~/AppData/Roaming/nushell/env.nu: nushell/env.nu
~/.config/nushell/env.nu: nushell/env.nu
~/.config/nushell/sfsu_.nu: nushell/sfsu_.nu
~/.cache/starship/init.nu: starship/init.nu
~/.bashrc: bashrc
~/.wezterm.lua: wezterm.lua
~/.config/starship.toml: starship/starship.toml
~/.config/powershell:
~/.config/alacritty.toml:
~/.config/whkdrc:
- shell:
- git submodule sync --recursive
# the following have to run after linking ~/.gitconfig
- git submodule update if nothing if precised after the :, on the Github repo will have the file at the root of the repo
- Pull changes to the remote repo
- Run the PowerShell script
install.ps1to create those symlink