Skip to content

feat(bash): split monolithic .bashrc into focused ~/.config/bash modules#151

Merged
bdossantos merged 4 commits into
masterfrom
copilot/improve-modernise-bash-shell
Jul 8, 2026
Merged

feat(bash): split monolithic .bashrc into focused ~/.config/bash modules#151
bdossantos merged 4 commits into
masterfrom
copilot/improve-modernise-bash-shell

Conversation

Copilot AI commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

.bashrc had grown to ~150 lines mixing options, completions, tool hooks, history, and SSH agent logic — hard to navigate and reason about load order.

Changes

New: ~/.config/bash/ modules

Module Responsibility
options.bash shopt flags + set -o vi
prompt.bash Ghostty integration + starship (PROMPT_COMMAND setter)
tools.bash brew, chruby, zoxide, direnv, fzf, gcloud, nomad
history.bash Prepends history -a to PROMPT_COMMAND — intentionally last
completions.bash System + Homebrew tab completions
ssh_agent.bash Auto-start/attach agent, add keys

Load order in .bashrc is explicit and annotated — history.bash must run after prompt.bash and tools.bash because both starship and direnv append to PROMPT_COMMAND before history -a is prepended.

.bashrc

Thin loader, ~40 lines, with guarded source calls and comments on ordering constraints.

.aliases fixes

  • Remove duplicate gd, c, q aliases
  • Fix tree fallback guard — [ ! -x "$(command -v tree &>/dev/null)" ] was always true (subshell output suppressed); replaced with ! command -v tree &>/dev/null
  • pserve: python -m SimpleHTTPServer (Python 2) → python3 -m http.server

README.md

Added Bash modules section with load-order table and required/optional tool inventory.

Split the monolithic .bashrc into six focused modules under
~/.config/bash/ that are sourced in a defined, documented order:

  options.bash     — shopt flags and set -o vi
  prompt.bash      — Ghostty integration + starship (sets PROMPT_COMMAND)
  tools.bash       — brew, chruby, zoxide, direnv, fzf, gcloud, nomad
  history.bash     — prepends 'history -a' to PROMPT_COMMAND last
  completions.bash — system-wide and Homebrew tab completions
  ssh_agent.bash   — auto-start / attach SSH agent

.bashrc is now a thin loader (~40 lines) with inline comments
explaining the load order and why it matters (PROMPT_COMMAND ordering).

Also clean up .aliases:
- remove duplicate aliases (gd, c, q)
- fix tree guard (was always true due to &>/dev/null in subshell)
- modernise pserve from python 2 SimpleHTTPServer to python3 http.server

Update README.md with a Bash modules table, required/optional tools,
and a note on the load-order contract.
Copilot AI changed the title feat(bash): modernise shell config with modular ~/.config/bash layout feat(bash): split monolithic .bashrc into focused ~/.config/bash modules Jul 8, 2026
Copilot AI requested a review from bdossantos July 8, 2026 11:28
@bdossantos bdossantos marked this pull request as ready for review July 8, 2026 11:55
Copilot AI review requested due to automatic review settings July 8, 2026 11:55
@bdossantos bdossantos merged commit 187acd1 into master Jul 8, 2026
1 check passed
@bdossantos bdossantos deleted the copilot/improve-modernise-bash-shell branch July 8, 2026 11:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the Bash configuration in this dotfiles repo by splitting the previous monolithic ~/.bashrc into a thin loader plus focused modules under ~/.config/bash/, and updates documentation/aliases to match.

Changes:

  • Introduces ~/.config/bash/*.bash modules (options, prompt, tools, history, completions, ssh-agent) and updates .bashrc to source them in an explicit order.
  • Cleans up .aliases (dedupes aliases, fixes tree fallback guard, updates pserve to Python 3).
  • Updates ignore rules and README documentation for the new Bash module structure.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Documents the new Bash module layout and load order.
.gitignore Adjusts tracked ~/.config subtrees to include the new bash modules directory.
.config/bash/options.bash Extracts shell options (shopt, set -o vi) into a dedicated module.
.config/bash/prompt.bash Extracts Ghostty + starship prompt initialization into a dedicated module.
.config/bash/tools.bash Extracts third-party tool hooks (brew/direnv/zoxide/fzf/etc.) into a dedicated module.
.config/bash/history.bash Ensures history -a is prepended to PROMPT_COMMAND after other setters.
.config/bash/completions.bash Extracts system + Homebrew completion initialization into a dedicated module.
.config/bash/ssh_agent.bash Extracts ssh-agent auto-start/attach and key loading into a dedicated module.
.bashrc Becomes a thin loader that sources modules in a documented order and then loads aliases/extra/zellij.
.aliases Removes duplicates and fixes/modernizes a few aliases and guards.

Comment thread .bashrc
Comment on lines +3 to 6
# ~/.bashrc — thin loader; all logic lives in ~/.config/bash/*.bash

# vi mode
set -o vi
_bash_config="${HOME}/.config/bash"

Comment thread .config/bash/prompt.bash
Comment on lines +7 to +10
if [[ -n "${GHOSTTY_RESOURCES_DIR}" ]]; then
# shellcheck source=/dev/null
builtin source "${GHOSTTY_RESOURCES_DIR}/shell-integration/bash/ghostty.bash"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants