Modshells is a command-line tool that transforms monolithic shell configuration files into a modular, maintainable directory structure. The tool:
Creates a standardised directory hierarchy for shell configurations
Detects installed shells on your system (Bash, Zsh, Fish, Nushell, and 6 others)
Injects sourcing logic into shell configuration files (with backup)
Ensures idempotency - safe to run multiple times without side effects
| Aspect | Status |
|---|---|
Directory creation | ✓ Working |
Shell detection | ✓ Working (checks /usr/bin, /bin, /usr/local/bin, /opt/homebrew/bin) |
Config backup | ✓ Working (timestamped backups before modification) |
Source injection | ✓ Working (shell-specific syntax for all 10 shells) |
Version 0.1 - Core functionality complete. The tool detects installed shells, backs up configs, and injects modular sourcing blocks.
After running modshells, your shell configurations are organised into:
~/.config/nushell/modshells/
├── core/ # PATH, prompt, history, shell options
├── tools/ # git, fzf, starship, direnv configs
├── misc/ # Custom aliases and functions
├── os/ # Linux vs macOS differences
└── ui/ # Themes and visual settingsEach shell’s config file (.bashrc, .zshrc, etc.) sources these directories automatically. Add a new alias? Drop a file into misc/. OS-specific tweak? Put it in os/. Done.
Traditional shell configuration becomes unwieldy:
Single files grow to hundreds of lines
Related configurations scattered throughout
Difficult to share configurations across shells
No clear separation of concerns
Risky manual editing of critical dotfiles
Modshells creates a standardised modular structure with shell-agnostic or shell-specific configuration snippets that are automatically sourced in order.
Modshells detects and manages configurations for ten shells:
| Shell | Status | Config File |
|---|---|---|
Bash | ✓ Supported |
|
Zsh | ✓ Supported |
|
Fish | ✓ Supported |
|
Nushell | ✓ Primary |
|
Ion | ✓ Supported |
|
Oils (OSH/YSH) | ✓ Supported |
|
Tcsh | ✓ Supported |
|
Ksh | ✓ Supported |
|
Dash | ◐ Limited |
|
PowerShell | ✓ Supported |
|
All Modshells operations are idempotent:
Running the tool multiple times produces the same result
Existing configurations are never destroyed
Automatic backup before any modification
Signature-based detection of already-modularised shells
src/
├── main/
│ └── modshells.adb # Entry point
├── config_store/
│ ├── config_store.ads # Configuration path interface
│ └── config_store.adb # Environment & path resolution
└── shell_manager/
├── shell_manager.ads # Shell operations interface
└── shell_manager.adb # Detection, creation, modularisationConfig_StoreResolves the modshells root path from
MODSHELLS_CONFIG_PATHenvironment variable or defaults to~/.config/nushell/modshellsShell_ManagerHandles shell detection, directory creation, modularisation checking, and configuration injection
GNAT (Ada compiler) - typically via
gnatorgcc-adapackageGPRBuild (GNAT project builder)
# Clone the repository
git clone https://github.com/hyperpolymath/modshells.git
cd modshells
# Build with GPRBuild
gprbuild -p -j0 modshells.gpr
# Binary is in bin/
./bin/modshells# Build and run
gprbuild -p -j0 modshells.gpr
./bin/modshellsExample output:
=== Modshells v0.1 ===
Configuration path: /home/user/.config/nushell/modshells
Creating modular directory structure...
Directories ready: core, tools, misc, os, ui
Detecting installed shells...
bash: [installed]
dash: [not found]
fish: [installed]
ion: [not found]
nushell: [installed]
tcsh: [not found]
zsh: [installed]
oils: [not found]
pwsh: [not found]
ksh: [not found]
Modularising shell configurations...
Modularising bash...
Backup created: /home/user/.bashrc.modshells-backup-20250101-120000
Injected modshells sourcing block.
Modularising fish...
Injected modshells sourcing block.
...
=== Modshells complete ===# Use custom configuration pathexport MODSHELLS_CONFIG_PATH="$HOME/.config/shells/modular"
modshells
# Target specific shells only
modshells init --shell=bash,zshAfter initialisation, add configuration snippets:
# Add a tool configurationecho'alias g="git"'>~/.config/nushell/modshells/tools/git.sh
# Add OS-specific configecho'export BROWSER=firefox'>~/.config/nushell/modshells/os/linux.shFiles are sourced alphabetically. Use numeric prefixes for ordering:
core/
├── 00-path.sh
├── 10-prompt.sh
└── 20-history.shMODSHELLS_CONFIG_PATHOverride default configuration root directory. Default:
~/.config/nushell/modshells
| Directory | Purpose |
|---|---|
| Essential shell settings: PATH modifications, prompt configuration, history settings, shell options |
| Tool integrations: git aliases, fzf configuration, starship prompt, direnv, asdf |
| General aliases, utility functions, one-off customisations |
| OS-specific configurations: Linux vs macOS differences, distro-specific settings |
| Visual customisations: colours, themes, terminal-specific settings |
The examples/ directory contains ready-to-use configuration snippets:
# Copy all examples to your modshells directory
cp -r examples/*~/.config/nushell/modshells/
# Or copy individual files
cp examples/tools/git.sh ~/.config/nushell/modshells/tools/
cp examples/misc/aliases.sh ~/.config/nushell/modshells/misc/| File | Description |
|---|---|
| PATH modifications for ~/.local/bin, Cargo, Go, Deno |
| History size, deduplication, timestamps, ignore patterns |
| Shell options (extglob, cdspell, globstar), editor, locale |
| Git aliases (gs, ga, gc, gp, gl, glog, etc.) |
| Fuzzy finder setup with fd integration |
| Starship prompt initialisation |
| Navigation (.., …), ls variants, safety nets (rm -i) |
| Utility functions: mkcd, extract, ff, fd, backup |
| Package manager aliases, systemd shortcuts |
| Homebrew setup, macOS-specific utilities |
| Terminal colours, GCC colours, man page colours |
| Custom bash prompt with git branch (fallback for non-starship) |
Run the shell-based smoke test to verify the build:
# From the repository root
./tests/smoke_test.shThe smoke test verifies:
Source files exist
Examples have correct structure
SPDX license headers present
Binary runs (if built)
Directory creation works
Idempotency check passes
Current version: v0.1
| Feature | Description |
|---|---|
Directory creation | Idempotently creates |
Path resolution | Reads |
Shell detection | Checks |
Config file backup | Creates timestamped backups ( |
Source injection | Appends shell-specific sourcing blocks with |
Shell-specific syntax | Generates correct sourcing code for all 10 shells (POSIX, Fish, Nushell, Tcsh, Ion, PowerShell) |
Idempotency | Signature-based detection prevents duplicate injections |
Build system | GPRBuild project files with CI/CD (GitHub Actions) |
See ROADMAP.adoc for planned features including:
Command-line arguments (
--shell=bash,zsh,--dry-run)Shell-agnostic
.modshellsconfig formatConfiguration drift detection
Snippet management commands
Contributions welcome. See CONTRIBUTING.md for guidelines.
This project follows the Rhodium Standard Repository (RSR) conventions.
This project is licensed under the Mozilla Public License, v. 2.0. See the LICENSE file for details.
SPDX-License-Identifier: CC-BY-SA-4.0
For academic use, see CITATIONS.adoc for BibTeX, Harvard, OSCOLA, MLA, and APA 7 formats.