No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-21 16:46:47 +01:00
files Publish the standalone Bash configuration tool 2026-11-21 15:49:12 +01:00
bashrc-config-menu.sh Rename the host module directory to bashrc-enabled 2026-11-21 15:58:27 +01:00
bashrc-config.sh Link Bash startup files and back up existing files on migration 2026-11-21 16:46:47 +01:00
COPYING.git-prompt Publish the standalone Bash configuration tool 2026-11-21 15:49:12 +01:00
git-prompt.sh Publish the standalone Bash configuration tool 2026-11-21 15:49:12 +01:00
install.sh Link Bash startup files and back up existing files on migration 2026-11-21 16:46:47 +01:00
load.sh Rename the host module directory to bashrc-enabled 2026-11-21 15:58:27 +01:00
module-order.sh Rename the host module directory to bashrc-enabled 2026-11-21 15:58:27 +01:00
README.md Link Bash startup files and back up existing files on migration 2026-11-21 16:46:47 +01:00

Bash startup on multiple hosts

Bashrc-config uses Bash 3.2 or later and standard system utilities. The login profile sources ~/.bashrc, which loads enabled modules from the Bash configuration directory. The configuration lives in ~/.config/bash or $XDG_CONFIG_HOME/bash when an absolute XDG_CONFIG_HOME is set.

Path Contents
bashrc-config/ Tool checkout, installer, and startup templates.
bashrc, bash_profile Local startup files linked from home.
bashrc-modules/ Separate checkout for shared modules.
bashrc-enabled/ Host-specific links and local modules.
bashrc-modules/.order Shared load order for enabled modules.
bashrc-modules/.default Modules enabled during a fresh installation.
startup-backup/ Original startup files saved during migration.

Interactive module menu

Run bashrc-config with no arguments to open the module menu below the prompt.

Key Action
Up / Down Select a module or move it while reordering.
Space Enable or disable the selected module on this host.
* Toggle whether the selected shared module is a default.
Enter Start moving the selected module, or save its new position.
Esc Cancel a move or close the menu.
E Edit the selected module.
A Create a disabled module and open it in the editor.
D Delete the selected file after confirmation.
I Move an inbox block into an existing or new module.
Q Close the menu.

Deleting a shared module also removes its managed link on this host. The menu removes its order entry when the module name no longer has a file or link on this host, and removes a deleted shared module from .default.

A * next to a module marks it as a default. This setting is stored in bashrc-modules/.default and can be shared with save and sync. Press Space to change whether the module is enabled on the current host.

The menu uses $VISUAL, then $EDITOR, then vi. Files placed directly in bashrc-enabled are marked [L]. You can edit and reorder them in the menu and manage their activation by moving the files yourself.

Use bashrc-config enable path.sh to create a local symlink to a shared module and bashrc-config disable path.sh to remove the link. Regular files placed directly in bashrc-enabled stay local.

Run bashrc-config order to show bashrc-modules/.order. Pass module filenames to replace the file's contents with your desired order. This example makes PATH and environment settings available before the prompt loads.

bashrc-config order path.sh env.sh prompt.sh

Both available and host-local modules can be listed. Use bashrc-config save and bashrc-config sync to share the new order. Each host keeps its own selection of enabled modules.

Each time .bashrc is sourced, it loads listed modules that are enabled on the current host. Remaining enabled .sh files run afterward in filename order. Blank lines, comments, and repeated entries are ignored. List a module before any module that depends on it. Older numbered module names still work.

Put conditions at the top of modules that only apply to certain shells.

[[ $- == *i* ]] || return 0       # Interactive shells
shopt -q login_shell || return 0  # Login shells

Put host-specific settings in separate modules and check that a tool or directory exists before using it.

Install

Set tool_url and modules_url to the Git URLs for the tool and your module repository. Run these commands for the default XDG location.

git clone -- "$tool_url" "$HOME/.config/bash/bashrc-config"
git clone -- "$modules_url" "$HOME/.config/bash/bashrc-modules"
bash "$HOME/.config/bash/bashrc-config/install.sh"
bash "$HOME/.config/bash/bashrc-config/install.sh" --apply

The installer copies the startup templates to bashrc and bash_profile in the Bash configuration directory and links ~/.bashrc and ~/.bash_profile to those local files.

For a test install, set HOME to a temporary directory and unset XDG_CONFIG_HOME before cloning. In a new interactive Bash session, append an alias and move it with the default choices. Answer y to confirm.

printf '\nalias hello="printf hello"\n' >> "$HOME/.bashrc"
bashrc-config cleanup

An interactive terminal shell shows a notice at startup if ~/.bash_profile or ~/.bashrc has any non-blank text below # bashrc-config inbox. Run bashrc-config inbox to check again during a session.

The installed .bashrc sources bashrc-config.sh in interactive shells. You can also source it from an existing shell to define bashrc-config. Sourcing the file leaves the shell options and traps alone. The function runs each command in a subshell, and bashrc-config.sh can also run directly.

source "${XDG_CONFIG_HOME:-${HOME}/.config}/bash/bashrc-config/bashrc-config.sh"
bashrc-config inbox

Press I in the module menu or run bashrc-config cleanup to move the block below the inbox marker. Choose interactive, login, or all. The default is interactive for .bashrc and login for .bash_profile.

Select an existing shared or local module by number to append to it. The appended block runs when both the chosen scope and the destination's existing guards allow it, and the module keeps its activation status. Enter a new name to create a shared module and enable it on this host. The command checks Bash syntax and shows both diffs before asking for confirmation. cleanup follows the links created by the installer to edit the local startup files.

Sync with Git

Run bashrc-config sync to fetch and fast-forward the module repository from its configured upstream branch. If there are local commits to publish, it pushes them to that same branch. If both branches have new commits, sync stops so you can decide how to reconcile them.

Use bashrc-config save to stage and commit changes in the module checkout before syncing. It includes additions, modifications, and deletions, and respects Git's ignore rules. It builds a message from the changed filenames, such as Update .order. If the filenames make the subject too long, it lists them in the commit body. Use bashrc-config save "Your message" to set your own message.

bashrc-config save
bashrc-config sync
bashrc-config update

Run bashrc-config update to fast-forward the tool checkout from its configured upstream. Open a new Bash session to load the updated tool. Use bashrc-config git to run a Git command in the module repository.

On a fresh host, the installer enables the available modules listed in bashrc-modules/.default. List one filename per line. Blank lines, comments, duplicate entries, and unavailable modules are ignored.

When bashrc-config sync pulls in a new module listed in .default, it enables it on this host if the name is available. Existing modules keep their local selection, including modules newly marked as defaults. Use bashrc-config enable or bashrc-config disable to change a host's selection. If an update removes a module, Bash skips the dangling link.

Existing startup files

The installer stops if it finds an existing startup file it does not manage. Use --migrate to preview the backup and links. Apply it after review from the tool checkout.

bash install.sh --migrate
bash install.sh --migrate --apply

Migration saves the original files in a new directory under startup-backup/ before installing the links. If an original was a symlink, its target's contents and the original link text are saved separately. If Bash was using .bash_login or .profile, the installer saves a copy and leaves the entry in the home directory. Bash will use the new .bash_profile at login.

Review the saved files and move any settings you want to keep into modules, or add them to the appropriate startup file's inbox and run cleanup. Backups stay outside the module loader. Preserve any system startup calls and check for existing calls to .bashrc before moving login code.

The installer creates bashrc-enabled/bashrc-local.sh for host-specific settings. The installer preserves existing copies.

The bundled Git prompt helper is distributed under the GNU General Public License version 2. See COPYING.git-prompt.