Normalisation et nettoyage #4

Open
xavier wants to merge 14 commits from dev into master
Owner
No description provided.
xavier added 13 commits 2026-08-22 02:25:36 +02:00
Merge rc.d/mcfly and rc.d/atuin into rc.d/history, following the same
preference-list + availability-check + fallback pattern as rc.d/prompt,
so only one history tool is active at a time instead of both being
initialized independently. Also normalize variable expansions in
rc.d/prompt to consistently use ${var} braces.
These files are always sourced (never executed directly), so the
#!/bin/bash shebang is inert and misleading. Drop it consistently
across rc.d/*, profile.d/*, and aliases.d/*.
Replace bare $var with ${var} everywhere it was still used, matching
the convention already established in rc.d/prompt and rc.d/history.
Positional parameters ($1, $@, $#) and special variables ($?, $$, $-)
are left as-is, consistent with existing usage in _helpers.bash.

rc.d/broot is auto-generated by the broot binary and will likely be
overwritten with its original formatting on the next broot update.
rc.d/anyenv, rc.d/screen, aliases.d/mc, and rc.d/startx were the last
holdouts still using `which` to check tool availability. Every other
file in rc.d/* already uses `command -v`, which doesn't depend on an
external binary being installed.
basedir() had a broken escape ($(dirname \"$-2\") makes no sense) and
was never called anywhere in the repo — it's a leftover copy of the
already-deprecated libs.deprecated/basedir.bash. bashrc already has
its own get_script_dir() for the same need, with proper symlink
resolution.
These files stay deprecated and out of the sourcing path for now, but
apply the same ${var} notation cleanup as the rest of the repo where
it's a pure notation fix. basedir.bash is left untouched: its bug is
a broken escape, not a notation issue, and it mirrors the one already
removed from _helpers.bash.
3rd-party/z (rupa/z) was declared but the directory doesn't exist on
disk, isn't in the git index, and nothing sources it — zoxide replaced
it as the cd-frecency tool (see rc.d/zoxide). complete-alias and
fzf-git.sh are left as-is; they still need to be initialized via the
chezmoi-managed external config that clones this repo (separate task).
rc.d/asdf tested native (~/.asdf) and Nix-profile asdf independently,
so if both were present on a machine, asdf would be sourced twice —
duplicate PATH entries and redefined completions/functions. Make the
Nix branch an elif so at most one is sourced.
profile.d/path and rc.d/rvm concatenated onto PATH directly, so
re-sourcing them in the same shell (source ~/.bashrc, a resourced
tmux pane, etc.) would duplicate entries. _path_add already guards
against that and tests directory existence itself.

profile.d/krew and profile.d/anyenv are left untouched: they prepend
to PATH (to take priority over other entries), while _path_add always
appends — converting them would silently change resolution order.
The removed loop tried to source /etc/bash*completion and
/etc/profile.d/bash*completion* by hand, with two real problems:
nullglob wasn't enabled for it (unlike everywhere else via
_source_dir_files), so an empty match sourced the literal glob
pattern and errored — the TODO already flagged this. It also
re-sourced /etc/profile.d/bash_completion.sh, a script meant for
/etc/profile on login shells, not for being re-run from an
interactive-only ~/.bashrc.

On a properly packaged system, bash-completion wires itself up
already (confirmed here via /etc/profile.d/bash_completion.sh and
progcomp being on by default) — this loop was dead weight at best and
a source of environment-dependent breakage at worst (seen previously
on Termux, where /etc doesn't have the same layout).
_path_add only ever appended to PATH, which didn't fit profile.d/krew
and profile.d/anyenv (they prepend, to take priority). Rename it to
_path_append for clarity and add _path_prepend alongside it, so both
orderings get the same dedup guard when needed — krew and anyenv
aren't converted yet, kept as plain PATH concatenation until then.
Both prepended to PATH directly, so re-sourcing them in the same
shell would duplicate entries — same issue _path_append already
fixed for profile.d/path and rc.d/rvm. _path_prepend keeps the same
priority ordering (these paths still take precedence over the rest
of PATH) while adding the dedup guard.
Replace the ~30-line get_script_dir() copy (duplicated a third time
from bashrc/bash_profile) with a one-liner. This script is always
executed directly, never sourced from another file, so BASH_SOURCE[0]
reliably points to itself — the extra logic in get_script_dir() for
the sourced-from-elsewhere case doesn't apply here.
xavier force-pushed dev from 34e2e7193c to e8c65f3205 2026-08-23 17:20:44 +02:00 Compare
xavier added 1 commit 2026-08-23 17:22:00 +02:00
xavier force-pushed dev from e8c65f3205 to 874d55625c 2026-08-23 17:22:00 +02:00 Compare
You are not authorized to merge this pull request.
This pull request can be merged automatically.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin dev:dev
git checkout dev
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: xavier/config-bash#4