A pattern for organising shell configuration into focused, manageable files. Works especially well with GNU Stow for dotfiles.
Add this to the end of your ~/.bashrc:
# Source additional shell configurations
if [ -d "$HOME/.bashrc.d" ]; then
for config in "$HOME/.bashrc.d"/*.sh; do
[ -r "$config" ] && source "$config"
done
fiUse numbered prefixes to control load order:
~/.bashrc.d/
├── 10-clipboard.sh
├── 20-fzf.sh
├── 21-zoxide.sh
├── 22-exa.sh
├── 25-nvim.sh
├── 30-project-workflow.sh
├── 40-nvm.sh
└── 70-powershell.sh
- Lower numbers load first
- Gaps give room for new files without renumbering
- 10s: core utilities, 20s: CLI tools, 30s: workflow, 40s: language runtimes
#!/bin/bash
# 22-exa.sh - modern ls replacement
if command -v exa &> /dev/null; then
alias ls='exa'
alias l='exa -la --icons'
alias t='exa --tree --icons'
fi#!/bin/bash
# 25-nvim.sh - editor configuration
if command -v nvim &> /dev/null; then
export EDITOR=nvim
export VISUAL=nvim
alias vi='nvim'
alias vim='nvim'
fiThe real power comes from combining with Stow. Each Stow package can contribute its own .bashrc.d/ file:
~/dotfiles/nvim/
├── .bashrc.d/
│ └── 25-nvim.sh # shell integration
└── .config/
└── nvim/
└── init.lua # editor config
Run stow nvim and both get symlinked. Unstow and the shell config disappears too.
Multiple packages merge into one .bashrc.d/ directory. No conflicts.
Full write-up: https://simoninglis.com/posts/modular-bashrc
Previous article: GNU Stow for dotfiles