|
|
5 日 前 | |
|---|---|---|
| bin | 5 日 前 | |
| dot_bashrc.d | 3 週間 前 | |
| dot_config | 1 ヶ月 前 | |
| README.md | 5 日 前 | |
| dot_bashrc | 2 ヶ月 前 | |
| dot_screenrc | 2 ヶ月 前 | |
| dot_vimrc | 2 ヶ月 前 | |
| setup.sh | 5 日 前 |
Personal dotfiles managed with chezmoi.
The repository lives at github.com/RalfBeckesch/dotfiles.git and is kept locally
under ~/.local/share/chezmoi.
| Protocol | URL |
|---|---|
| SSH | git@github.com:RalfBeckesch/dotfiles.git |
| HTTPS | https://github.com/RalfBeckesch/dotfiles.git |
# SSH
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b ~/.local/bin init --apply git@github.com:RalfBeckesch/dotfiles.git
# HTTPS (no SSH key required)
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b ~/.local/bin init --apply https://github.com/RalfBeckesch/dotfiles.git
# SSH
chezmoi init git@github.com:RalfBeckesch/dotfiles.git
# HTTPS
chezmoi init https://github.com/RalfBeckesch/dotfiles.git
Alternatively, use the setup.sh script in this repository, which installs chezmoi
and applies the dotfiles if that hasn't happened yet. The setup.sh is intended to be used as devpod quick setup.
see setup.sh
# Alpine
apk add chezmoi
# Arch
pacman -S chezmoi
# Debian
apt-get install chezmoi
# Fedora
dnf install chezmoi
# NixOS
nix-env -i chezmoi
# openSUSE Tumbleweed
zypper install chezmoi
# RHEL (EPEL)
dnf install epel-release && dnf install chezmoi
# Termux
pkg install chezmoi
# Void
xbps-install -S chezmoi
# am
am -i chezmoi
# asdf
asdf plugin add chezmoi && asdf install chezmoi 2.72.2
# mise
mise use --global chezmoi@2.72.2
# Homebrew
brew install chezmoi
# Nix
nix-env -i chezmoi
# Snap
snap install chezmoi --classic
| Path | Description |
|---|---|
dot_bashrc |
Entry point for ~/.bashrc; loads all snippets from ~/.bashrc.d (interactive shells only) |
dot_bashrc.d/ |
Modular bash config snippets, loaded in alphabetical/numeric order |
dot_bashrc.d/applications/ |
Application-specific aliases and additions, loaded by 150-applications.sh (cd, chezmoi, containerlab, date, devpod, grep, kubernetes, ls/lsd, mkdir, ssh, starship, sudo, vi/nvim) |
dot_config/ |
Config files under ~/.config/ (e.g. symlink to starship.toml) |
empty_dot_bash_aliases |
Empty ~/.bash_aliases file (placeholder) |
bin/ |
Wrapper scripts for companion repositories (see below) |
setup.sh |
Bootstrap script: installs chezmoi and applies the repository |
The numbered files in dot_bashrc.d/ are sourced in this order:
000-bash-setup-generic.sh – basic shell setup010-bash-account-specific.sh – account-/machine-specific settings100-generic-aliases.sh – general aliases150-applications.sh – loads all snippets in applications/200-networking.sh – networking aliases and helpers300-shell-safety-nets.sh – safety nets (e.g. safer aliases)Files with a suffix not equal to .sh (e.g. mybashrc.sh-off) are intentionally not loaded.
This public dotfiles repo is the first of three chezmoi instances that work together but manage disjoint target files:
| Instance | Source directory | Git repository | Content | Protection |
|---|---|---|---|---|
chezmoi |
~/.local/share/chezmoi |
git@github.com:RalfBeckesch/dotfiles.git |
Public shell config, aliases, portable tools | None (public) |
chezmoi-private |
~/.local/share/chezmoi-private |
git.beckesch.it:rb/chezmoi-private.git |
SSH config, ~/.hermes/config.yaml, personal settings |
Repository access control |
chezmoi-secrets |
~/.local/share/chezmoi-secrets |
git.beckesch.it:rb/chezmoi-secrets.git |
API tokens, .env files, credentials |
Repository access + age encryption |
All three instances use the same chezmoi binary but different source directories,
config files, and (for secrets) persistent state. They deploy into the same $HOME
without conflict because no target file is managed by more than one instance.
| Target file | Managed by |
|---|---|
~/.bashrc, public shell snippets |
Public repo (chezmoi) |
~/.ssh/config |
Private repo (chezmoi-private) |
~/.ssh/authorized_keys |
Private repo (chezmoi-private) |
~/.hermes/config.yaml |
Private repo (chezmoi-private) |
| Private SSH key files | Separate provisioning (never in any repo) |
~/.hermes/.env |
Secrets repo (chezmoi-secrets) |
Two wrapper scripts in bin/ provide dedicated command names for the companion
repositories. Each wrapper invokes chezmoi with the correct --config and
--source flags so every command targets the right instance.
Purpose: Version-controlled private configuration that does not belong in the public dotfiles repo — SSH config, Hermes configuration, personal scripts.
Wrapper (bin/executable_chezmoi-private.sh):
#!/bin/sh
exec chezmoi \
--config "$HOME/.config/chezmoi-private/chezmoi.toml" \
--source "$HOME/.local/share/chezmoi-private" \
"$@"
Bootstrap on a new machine:
# 1. Create the directory structure
mkdir -p ~/.local/bin ~/.config/chezmoi-private ~/.local/share/chezmoi-private
# 2. Install the wrapper (this repo provides it as bin/executable_chezmoi-private.sh)
# Copy it manually or let the public dotfiles repo deploy it:
cp /path/to/dotfiles/bin/executable_chezmoi-private.sh ~/.local/bin/chezmoi-private
chmod 755 ~/.local/bin/chezmoi-private
# 3. Create an empty local config
touch ~/.config/chezmoi-private/chezmoi.toml
chmod 600 ~/.config/chezmoi-private/chezmoi.toml
# 4. Initialize from the remote repository
chezmoi-private init git@git.beckesch.it:rb/chezmoi-private.git
# 5. Review before applying — personal config may contain host-specific values
chezmoi-private diff
chezmoi-private apply
Daily workflow:
# Add a file to the private repo
chezmoi-private add ~/.ssh/config
# Edit a managed file (chezmoi handles the source → target mapping)
chezmoi-private edit ~/.ssh/config
chezmoi-private apply
# Review pending changes
chezmoi-private status
chezmoi-private diff
# Fetch and apply remote changes
chezmoi-private update
# Git operations from the source directory
git -C ~/.local/share/chezmoi-private status
git -C ~/.local/share/chezmoi-private add --all
git -C ~/.local/share/chezmoi-private commit -m "Update private config"
git -C ~/.local/share/chezmoi-private push
Host-specific template values:
Local config ~/.config/chezmoi-private/chezmoi.toml:
[data]
hostRole = "workstation"
sshIdentityFile = "~/.ssh/id_ed25519_personal"
Mark a managed file as a template and inject these values:
chezmoi-private chattr +template ~/.ssh/config
chezmoi-private edit ~/.ssh/config
Inside the template use {{ .sshIdentityFile }} etc. The local config stays
on each host — it is not distributed through the repository.
Rules:
diff before applyprivate_ in chezmoi filenames = restrictive file permissions, not encryptionPurpose: Version-controlled encrypted secrets — API tokens, .env files,
and other credentials. File contents are encrypted with age
at rest; the repository never sees plaintext.
Wrapper (bin/executable_chezmoi-secrets.sh):
#!/bin/sh
exec chezmoi \
--config "$HOME/.config/chezmoi-secrets/chezmoi.toml" \
--source "$HOME/.local/share/chezmoi-secrets" \
--persistent-state "$HOME/.config/chezmoi-secrets/chezmoistate.boltdb" \
"$@"
Note the --persistent-state flag — the secrets instance has its own BoltDB
state file, keeping it fully isolated from the public and private instances.
~/.config/chezmoi-secrets/age-key.txt).Step 1 — Create the directories and install the wrapper:
mkdir -p ~/.local/bin ~/.config/chezmoi-secrets ~/.local/share/chezmoi-secrets
chmod 700 ~/.config/chezmoi-secrets ~/.local/share/chezmoi-secrets
cp /path/to/dotfiles/bin/executable_chezmoi-secrets.sh ~/.local/bin/chezmoi-secrets
chmod 755 ~/.local/bin/chezmoi-secrets
Step 2 — Generate an age keypair (first host only):
(
umask 077
chezmoi-secrets age-keygen --output="$HOME/.config/chezmoi-secrets/age-key.txt"
)
chmod 600 "$HOME/.config/chezmoi-secrets/age-key.txt"
The command prints the public key (age1...). Copy it — you will need it
for the config. Back up age-key.txt separately (password manager,
encrypted offline backup). Without it, encrypted files in the repository
are unrecoverable.
Step 3 — Create the local config:
touch ~/.config/chezmoi-secrets/chezmoi.toml
chmod 600 ~/.config/chezmoi-secrets/chezmoi.toml
Step 4 — Configure encryption:
# ~/.config/chezmoi-secrets/chezmoi.toml
encryption = "age"
useBuiltinAge = true
[add]
encrypt = true
[age]
identity = "~/.config/chezmoi-secrets/age-key.txt"
recipient = "age1_YOUR_PUBLIC_KEY"
add.encrypt = true is a helpful default but not a policy — manually written
files in the source directory are not automatically encrypted. Always verify
before committing.
Step 5 — Initialize the repository and apply:
chezmoi-secrets init git@git.beckesch.it:rb/chezmoi-secrets.git
chezmoi-secrets diff # verify before applying
chezmoi-secrets apply
# Add an existing .env file
chezmoi-secrets add --encrypt ~/.hermes/.env
# Optionally set restrictive permissions explicitly
chezmoi-secrets chattr +private ~/.hermes/.env
Verify the source file is actually encrypted:
chezmoi-secrets status
git -C ~/.local/share/chezmoi-secrets diff --cached
# Should show encrypted content, not plaintext
# Edit a secret safely — chezmoi decrypts to a private temp dir, opens your
# editor, then re-encrypts when you close it
chezmoi-secrets edit ~/.hermes/.env
chezmoi-secrets apply ~/.hermes/.env
# Status and diff (WARNING: diff decrypts for display)
chezmoi-secrets status
chezmoi-secrets diff ~/.hermes/.env
# Git status and push
git -C ~/.local/share/chezmoi-secrets status
git -C ~/.local/share/chezmoi-secrets add --all
git -C ~/.local/share/chezmoi-secrets commit -m "Update secrets"
git -C ~/.local/share/chezmoi-secrets push
# Update from remote (controlled — no auto-apply)
git -C ~/.local/share/chezmoi-secrets pull --ff-only
chezmoi-secrets apply ~/.hermes/.env
Shared key — simplest model: copy age-key.txt to each host via a secure
channel (password manager, encrypted USB). Use the same recipient in every
config. Configuration on the next host is identical except for steps 2-4.
Per-host keys — each host gets its own keypair. Add all public keys as recipients:
[age]
identity = "~/.config/chezmoi-secrets/age-key.txt"
recipients = [
"age1PUBLIC_KEY_LAPTOP",
"age1PUBLIC_KEY_DESKTOP",
]
Important limits with per-host keys:
add --encrypt on an already
authorized host.[add] encrypt = true is setgit diff --cached)exact_ directory removes files managed by another instancePurpose: Helper script to bootstrap a new companion chezmoi repository — creates
the wrapper script with correct --config and --source paths for a custom
instance name.
Script (bin/executable_chezmoi_create-custom.sh):
#!/bin/sh
# Usage: ./bin/executable_chezmoi_create-custom.sh <name>
#
# Creates ~/bin/chezmoi-<name>.sh with:
# --config "$HOME/.config/chezmoi-<name>/chezmoi.toml"
# --source "$HOME/.local/share/chezmoi-<name>"
#
# Exits with an error if any of the three files/directories already exist.
Usage example — creating a chezmoi-work instance:
# Create the wrapper
./bin/executable_chezmoi_create-custom.sh work
# Set up the companion repo manually (wrapper exists, but config + source
# directories are still empty)
mkdir -p ~/.config/chezmoi-work ~/.local/share/chezmoi-work
touch ~/.config/chezmoi-work/chezmoi.toml
chmod 600 ~/.config/chezmoi-work/chezmoi.toml
# Initialize from a remote
chezmoi-work init git@example.com:user/chezmoi-work.git
chezmoi-work diff
chezmoi-work apply
The script is idempotent — it refuses to overwrite an existing wrapper, config, or source directory. Delete those manually if you need to recreate an instance.
# Bring a file from your home directory into the public repo
chezmoi add ~/.bashrc.d/my-snippet.sh
# Edit a managed file
chezmoi edit ~/.bashrc.d/my-snippet.sh
# Update and apply the public dotfiles
chezmoi update
# Show the diff between the repo and the actual home directory
chezmoi diff
# Sync on another machine
chezmoi cd # opens the source directory; then git pull/push as usual
The file ~/.BASHRC_DEBUG controls the debug output of ~/.bashrc:
If it exists, its content is set as the debug level and messages are printed while
the snippets are loaded (see debug() in dot_bashrc).