Use Chezmoi to guarantee idempotency of terminal

Wazaterm allows you to create a new terminal easily and simply. You can use dotfile’s management tool chezmoi (pronounced “chez-moi”) to save your time and effort for the initial setup.

Install chezmoi

Install chezmoi as described in the documentation with the following command.

$ sh -c "$(curl -fsLS"
info found version 2.7.5 for latest/linux/amd64
info installed . /bin/chezmoi

Chezmoi will be installed in $HOME/bin, so set the path. You can set it when you need it, or you can put the path in a .bashrc or something.

$ export PATH=/home/shohey1226/bin:$PATH 
or add the above line in .bashrc or the other rc files that you use.


The init command will create a directory.

$ chezmoi init
$ ls -al ~/.local/share/chezmoi
total 0

drwxrwxr-x 1 shohey1226 shohey1226 8 Nov 19 01:21 .
drwx------ 1 shohey1226 shohey1226 140 Nov 19 01:21 .
drwxrwxr-x 1 shohey1226 shohey1226 98 Nov 19 01:21 .git

Let’s register the files we need as soon as possible. If the file you want to register is a symbolic link, you can use --follow.

$ chezmoi add --follow .tmux.conf 
$ chezmoi add --follow .vimrc
$ chezmoi add .config/nvim/init.vim # this is a symlink to .vimrc. I'm sharing the config on neovim and vim8
# I'm using fish and back up entire directory
I'm sharing the config on neovim and vim8 # I'm using fish and back up the entire directory

If you register a file with a name starting with run_once, that file will be the first script to run.

$ chezmoi add
$ head -n 10 .local/share/chezmoi/                                                              
#! /bin/bash
sudo apt-get -y update
# nvm
curl -o- | bash
. .nvm/
npm install yarn -g
$ chezmoi add
$ cat .local/share/chezmoi/
#! /bin/bash
git config --global xxx
git config --global "Shohei"

Then reflect it with apply and register it on github.

$ chezmoi apply
$ chezmoi cd
$ git add .
$ git commit -m "Initial commit"
# create dotfiles repo 
$ git remote add origin
$ git branch -M main
$ git push -u origin main

One-shot setup in a new terminal

$ curl -fsLS | sh -
$ . /bin/chezmoi init <a href=""></a>
$ chezmoi apply -v