Modular Bash configuration based on the Unix .d directory pattern (similar to /etc/profile.d/ or conf.d/). Scripts are sourced dynamically in lexicographical order at shell startup.
- Bash 4.0+
- jq (required by
.init.sh)
-
Add initialization snippet to
~/.bashrc(or~/.bash_profilefor macOS login shells):# Initialize ~/.bashrc.d [[ -s "${HOME}/.bashrc.d/.init.sh" ]] && source "${HOME}/.bashrc.d/.init.sh"
-
Clone repository:
git clone https://github.com/detro/.bashrc.d.git ~/.bashrc.d -
Launch a new shell session.
To maintain machine-specific configurations, sensitive tokens, or personal preferences without committing them to version control, use the *.private.* pattern ignored by .gitignore:
- Private scripts (
*.private.sh): Drop any script ending in.private.shinto~/.bashrc.d/(e.g.,10-work-paths.private.sh)..init.shautomatically discovers and sources it in alphabetical order alongside public scripts. - Private data/config (
*.private.json): Store secrets, structured configs, or metadata consumed by companion scripts without exposure.
- Interactive shells: Each script emits informative, colored log lines (
info,warn,error) reporting which tools, paths, completions, and aliases are loaded. - Coding agent shells: When
$AGENTis set,.init.shdetects that the shell was spawned by an AI coding agent, logs a single header line, and silences all startup log messages to keep command output clean and prevent LLM context window pollution.
Located in 26-1password_macos_cache.sh.
Exporting environment variables from 1Password via CLI (export TOKEN=$(op read ...)) triggers Touch ID or master password prompts on every single new terminal tab or shell instance.
OPMC uses the macOS Keychain (via the native security CLI) as a secure local cache. The Keychain unlocks automatically on login.
- First run: Retrieves secret from 1Password (
op read), caches it into macOS Keychain, then exports it. - Subsequent shells: Reads directly from macOS Keychain instantly, bypassing 1Password prompts.
Create 26-1password_macos_cache.private.json in the root directory:
{
"secrets": [
{
"envVar": "NPM_TOKEN",
"opSecRef": "op://Private/npm/credential",
"opVault": "Private",
"opAccURL": "my-account.1password.com"
}
]
}opmc_export_all: Refresh environment variables from cache (runs on startup).opmc_clear <ENV_VAR>: Invalidate a specific cached secret.opmc_clear_all: Wipe all configured secrets from Keychain cache to force 1Password reload.
The Unlicense (Public Domain).