|
|
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 |
One-command init — deploys shell config, aliases, tools and the
wrapper binaries for the companion repositories into ~/.local/bin/:
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b ~/.local/bin init --apply git@github.com/RalfBeckesch/dotfiles.git
Optional companion instances (run after the public repo is applied):
chezmoi-private init --apply <your-private-repo-url> # see ## chezmoi-private
chezmoi-secrets init --apply <your-secrets-repo-url> # see ## chezmoi-secrets (age key may be needed)
Use setup.sh from this repository — it installs chezmoi and applies the
public dotfiles without asking for a repo URL (devpods only).
# 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 |
Secrets repo (chezmoi-secrets, age-encrypted) |
~/.hermes/config.yaml |
Private repo (chezmoi-private) |
| Private SSH key files | Secrets repo (chezmoi-secrets, age-encrypted) |
~/.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:
Prerequisites: the public dotfiles must be applied first (the wrapper binary
chezmoi-private lands at ~/.local/bin/chezmoi-private via the public repo).
# Initialize and apply from the remote repository
chezmoi-private init --apply git@git.beckesch.it:rb/chezmoi-private.git
# Review before applying — personal config may contain host-specific values
chezmoi-private diff
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).Prerequisites: the public dotfiles must be applied first (the wrapper binary
chezmoi-secrets lands at ~/.local/bin/chezmoi-secrets via the public repo).
Step 1 — 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 2 — Create the local config:
touch ~/.config/chezmoi-secrets/chezmoi.toml
chmod 600 ~/.config/chezmoi-secrets/chezmoi.toml
Step 3 — 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 4 — 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).