Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,20 @@ jobs:

- name: 🧪 urda.bash Testing
run: make test

- name: 💨 urda.bash Smoke Test
run: make smoke

smoke-macos:
runs-on: macos-latest

steps:
# https://github.com/marketplace/actions/checkout
- name: ⬇️ Checkout
uses: actions/checkout@v5

- name: 🔍 Report `bash` Version
run: /bin/bash --version

- name: 💨 urda.bash Smoke Test (bash 3.2)
run: make smoke SMOKE_BASH=/bin/bash
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
# CHANGELOG

## 2.2.0

This is an enhancement, housekeeping, and bugfix release.

- `bashrc`
- Added extension drop-in loading: `*.sh` files in `~/.config/urda.bash/extensions.d/` are sourced in sorted order after core files and before `bash_secrets`.
- Added `URDABASH_LOADED_EXTENSIONS` count of loaded extensions.
- Moved `_prepend_path_once` in from `bash_functions` so PATH setup no longer depends on another file loading.
- Guarded the startup version check so a partial install fails quietly.
- Fixed the git and screen prompt lines to treat branch and session names as data, closing a command injection path through prompt expansion.
- Fixed XDG variables to respect values already set by the environment.
- Fixed a stray `pc` variable leaking into every shell.
- Fixed the `pnpm` PATH entry to use `${PNPM_HOME}/bin`, where pnpm v11 stores global binaries.
- `bash_aliases`
- Removed `get_uuid` alias (now a function, see `bash_functions`).
- `bash_exports`
- Fixed `GPG_TTY` to declare and export separately.
- `bash_functions`
- Added `get_uuid` function with fallbacks: `uuidgen`, the Linux kernel, then `python3`. Output is lowercase on all platforms.
- Added input validation to `bak`.
- Added `URDABASH_LOADED_EXTENSIONS` to `_urdabash_info`.
- Fixed `psg` to treat multiple words as a single search pattern.
- Fixed `unarc` to return an error on unknown archive types and print errors to stderr.
- Moved `_prepend_path_once` to `bashrc`.
- Reordered `_urdabash_update` before `_urdabash_version_check` to restore alphabetical order.
- `Makefile`
- Added `release-check` target for documentation parity checks.
- Added `smoke` target that boots bashrc in a clean shell against a temp HOME, including extension loader checks; `SMOKE_BASH` selects the shell under test.
- Added `install.sh` and `release_check.sh` to shellcheck coverage.
- Removed the SC2155 shellcheck exclusion.
- Switched variable references to braced style.
- `README.md`
- Documented the Extensions drop-in directory, including a trust warning.
- Documented the `release-check` and smoke targets.
- Updated `get_uuid` documentation (alias to function).
- `release_check.sh`
- New script verifying aliases and functions agree across the code, the help screen, and the README, and that all lists stay alphabetized.
- `.github/workflows/testing.yaml`
- Added the smoke test to the Ubuntu job.
- Added a macOS job running the smoke test under `/bin/bash` 3.2.

## 2.1.3

This is a bugfix release.
Expand Down
42 changes: 35 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ DIFF := $(firstword $(shell which colordiff diff))
DIFF_ARGS := -u
MANIFEST_IGNORE := bash_history|bash_secrets
SHELLCHECK := $(shell which shellcheck)
SHELLCHECK_ARGS := --shell=bash -e SC1090 -e SC1091 -e SC2009 -e SC2155 -o require-variable-braces
SHELLCHECK_FILES := $(addprefix ./,$(shell cat MANIFEST))
SMOKE_BASH := bash
SHELLCHECK_ARGS := --shell=bash -e SC1090 -e SC1091 -e SC2009 -o require-variable-braces
SHELLCHECK_FILES := $(addprefix ./,$(shell cat MANIFEST)) ./install.sh ./release_check.sh

########################################################################################################################
# Commands
Expand All @@ -22,7 +23,7 @@ SHELLCHECK_FILES := $(addprefix ./,$(shell cat MANIFEST))
# `make help` needs to be first so it is ran when a bare `make` is called.
.PHONY: help
help: # Show this help screen
@grep -E '^[a-zA-Z_-]+:.*# .*$$' $(MAKEFILE_LIST) |\
@grep -E '^[a-zA-Z_-]+:.*# .*$$' ${MAKEFILE_LIST} |\
sort -k1,1 |\
awk 'BEGIN {FS = ":.*?# "}; {printf "\033[1m%-30s\033[0m %s\n", $$1, $$2}'

Expand All @@ -38,27 +39,54 @@ copy: # Copy the local bash configs into your home directory (DESTRUCTIVE).
diffs: # Run a diff against your local shell files against this repo's shell files.
@while IFS= read -r file; do \
echo "diff ~/.$${file} ./$${file}"; \
$(DIFF) $(DIFF_ARGS) "$${HOME}/.$${file}" "./$${file}" || :; \
${DIFF} ${DIFF_ARGS} "$${HOME}/.$${file}" "./$${file}" || :; \
done < MANIFEST

.PHONY: manifest-check
manifest-check: # Validate MANIFEST matches managed bash files.
@repo_files=$$(ls -1 bash* | grep -Ev '$(MANIFEST_IGNORE)' | sort); \
@repo_files=$$(ls -1 bash* | grep -Ev '${MANIFEST_IGNORE}' | sort); \
manifest_files=$$(sort MANIFEST); \
if [ "$${repo_files}" = "$${manifest_files}" ]; then \
echo "MANIFEST is up to date"; \
exit 0; \
else \
echo "MANIFEST mismatch:"; \
$(DIFF) $(DIFF_ARGS) --label REPO --label MANIFEST <(echo "$${repo_files}") <(echo "$${manifest_files}"); \
${DIFF} ${DIFF_ARGS} --label REPO --label MANIFEST <(echo "$${repo_files}") <(echo "$${manifest_files}"); \
exit 1; \
fi

.PHONY: release-check
release-check: # Run release checklist parity checks (docs vs code).
release-check: version-check
release-check: manifest-check
./release_check.sh

.PHONY: smoke
smoke: # Boot bashrc in a clean interactive shell against a temp HOME.
@tmp_home=$$(mktemp -d); \
while IFS= read -r file; do \
cp "$${file}" "$${tmp_home}/.$${file}"; \
done < MANIFEST; \
mkdir -p "$${tmp_home}/.config/urda.bash/extensions.d"; \
echo 'SMOKE_ORDER="$${SMOKE_ORDER}10-"' > "$${tmp_home}/.config/urda.bash/extensions.d/10-a.sh"; \
echo 'SMOKE_ORDER="$${SMOKE_ORDER}20"' > "$${tmp_home}/.config/urda.bash/extensions.d/20-b.sh"; \
echo 'SMOKE_ORDER="BROKEN"' > "$${tmp_home}/.config/urda.bash/extensions.d/notes.txt"; \
env -i HOME="$${tmp_home}" PATH="$${PATH}" TERM=dumb \
${SMOKE_BASH} -i -c '_urdabash_info && _urdabash_help >/dev/null \
&& [ "$${URDABASH_LOADED_EXTENSIONS}" = "2" ] \
&& [ "$${SMOKE_ORDER}" = "10-20" ]' \
>/dev/null 2>"$${tmp_home}/stderr.log"; \
status=$$?; \
grep -vE "job control|ioctl" "$${tmp_home}/stderr.log" >&2 || :; \
rm -rf "$${tmp_home}"; \
if [ $${status} -eq 0 ]; then echo "smoke OK"; else echo "smoke FAILED"; fi; \
exit $${status}

.PHONY: test
test: # Test and check shell scripts for issues.
test: version-check
test: manifest-check
$(SHELLCHECK) $(SHELLCHECK_ARGS) $(SHELLCHECK_FILES)
${SHELLCHECK} ${SHELLCHECK_ARGS} ${SHELLCHECK_FILES}

.PHONY: test-update
test-update: # Test _urdabash_update against localhost:8000 (run 'serve' first).
Expand Down
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This is a collection of my bash prompt settings, aliases, exports, and other rel
- [`pnpm`](https://pnpm.io/) support.
- Weekly `VERSION` check against GitHub remote (non-blocking).
- Also supports on-demand version checking with `_urdabash_version_check now`
- Extension drop-in directory (`~/.config/urda.bash/extensions.d/`).

Should work with `bash 3.2` or higher.

Expand All @@ -33,7 +34,6 @@ Should work with `bash 3.2` or higher.
- `dadjoke` - Random dad joke from `icanhazdadjoke.com`.
- `diff` - Unified diff format, with color via `colordiff` when available.
- `epoch` - Print current unix timestamp (seconds).
- `get_uuid` - Generate a random UUID.
- `headers` - Fetch HTTP response headers only.
- `ll` - Long listing format (`ls -hlF`).
- `moon` - Current moon phase via `wttr.in`.
Expand All @@ -54,6 +54,8 @@ Should work with `bash 3.2` or higher.
- Back up a file with a `.bak` extension.
- `coinflip`
- Flip a coin.
- `get_uuid`
- Generate a random lowercase UUID (`uuidgen`, Linux kernel, or `python3`, whichever is present).
- `mkcd`
- Create a directory and `cd` into it in one step.
- `psg`
Expand Down Expand Up @@ -111,6 +113,27 @@ Version check state is stored at `${XDG_STATE_HOME}/urda.bash/` (`~/.local/state
- `last_check` - Timestamp file used to determine when the next fetch is due.
- `remote_version` - Cached remote version string from the last successful fetch.

### Extensions

Drop `*.sh` files into `${XDG_CONFIG_HOME}/urda.bash/extensions.d/`
(`~/.config/urda.bash/extensions.d/`) and they are sourced automatically at
shell startup, in sorted order, after the core urda.bash files and before
`bash_secrets` and `bash_local`. Use `NN-` prefixes to control load order:

```text
10-bw-session.sh
20-work-tools.sh
```

The directory is optional and never touched by the updater. `_urdabash_info`
reports how many extensions loaded via `URDABASH_LOADED_EXTENSIONS`.

#### A Word on Trust

Sourcing an extension is running shell code in every interactive shell, with
everything your user can do. Only place files you trust in this directory,
and inspect anything you did not write yourself before your next shell starts.

### Local Customizations

If `~/.bash_local` exists, it is sourced automatically after all other files. Use this file for machine-specific aliases, functions, or overrides that should survive upgrades.
Expand Down Expand Up @@ -141,6 +164,20 @@ This will also run a `make version-check`.
make test
```

### Smoke test

Boot the managed files in a clean interactive shell against a temporary `HOME`:

```bash
make smoke
```

Set `SMOKE_BASH` to select the shell under test:

```bash
make smoke SMOKE_BASH=/bin/bash
```

### Copying files to your `${HOME}`

**WARNING!** This is a **DESTRUCTIVE** operation and copies `bash` files from the project into your `${HOME}`.
Expand All @@ -152,3 +189,13 @@ make copy
### Project version check

Just run `make version-check`.

### Release checks

Before cutting a release, run the documentation parity checks:

```bash
make release-check
```

This verifies that every alias and function agrees across the code, the `_urdabash_help` screen, and this README, that each list is alphabetized, and runs the version and MANIFEST checks.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.3
2.2.0
3 changes: 0 additions & 3 deletions bash_aliases
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ fi
# current unix epoch in seconds
alias epoch='date +%s'

# get a UUID on demand
alias get_uuid='python3 -c "import uuid;print(uuid.uuid4())"'

# fetch HTTP response headers only
alias headers='curl -sI --max-time 5'

Expand Down
3 changes: 2 additions & 1 deletion bash_exports
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export GIT_PS1_SHOWSTASHSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true

# GPG
export GPG_TTY="$(tty)"
GPG_TTY="$(tty)"
export GPG_TTY

# History Settings
export HISTCONTROL=ignoreboth
Expand Down
Loading