“…or how I learned to stop worrying and push my Bash to the internet.”
1. Introduction
In the previous episode of “Me Decide to Hack His Shell,” I introduced the HHGTTG Bash Module — a tiny but "mighty" addition to your Bash prompt that brings a spinner, event hooks, and just enough flair to make daily terminal work slightly more absurd and considerably more enjoyable.
But writing a module is one thing.
Publishing it?
That’s a whole different adventure.
Because once your code leaves the safety of your /home directory, it begins a new life in the open wild. It starts interacting with other people’s shells. It gets judged. Cloned. Copy-pasted into strange machines in far-off galaxies. And that means we must prepare it properly.
So today’s post is about:
✔ Publishing the module to GitHub
✔ Structuring the repository
✔ Choosing the right filenames
✔ Adding documentation that won’t send your readers screaming into the void
✔ Ensuring everything looks clean, intentional, and professional
Let’s begin.
2. Why GitHub?
GitHub is the modern equivalent of placing your code on a towel — a way to claim your space in the coding universe while ensuring others can reliably find, view, fork, or ignore your work with ease.
Publishing your module gives you:
- Version control – so you know what you broke and when.
- Backups – your shell scripts will no longer vanish with your laptop battery.
- Visibility – others can contribute ideas, issues, or praise.
- Easy installation – users can curl, wget, or git clone your work.
3. Preparing Your Module for Public Consumption
Before publishing your Bash module, you must make sure it’s presentable — like brushing your teeth before opening the door.
3.1 Repository structure
Here is a clean and simple layout:
hhgttg-bash/
├── README.md
├── install.sh
├── hhgttg.sh
├── bash-preexec.sh
└── test/
3.2 README.md structure
A good README.md answers three questions:
- What is this?
- How do I install it?
- Why should I care?
For example:
# HHGTTG Bash Module
A simple Bash extension that adds preexec/precmd hooks, a command spinner,
and other fun functionality inspired by *The Hitchhiker’s Guide to the Galaxy*.
## Installation
```bash
curl -s https://raw.githubusercontent.com/<username>/hhgttg-bash/main/install.sh | bash
Features
- Spinner animation before slow commands
- Pre-exec and pre-cmd hooks via
bash-preexec.sh - Customizable module behaviour
- Clean install/uninstall
---
## **4. The Code You Publish**
Let’s look at the core files users will see.
### **4.1. `hhgttg.sh`**
This is the heart of your module — your custom logic, spinner, and hooks.
Example:
```bash
start_spinner() {
CHARS='|/-\'
while true; do
for c in $CHARS; do
printf "\r[$c] Working..."
sleep 0.1
done
done
}
stop_spinner() {
[[ -n "$SPINNER_PID" ]] && kill "$SPINNER_PID" 2>/dev/null
printf "\rDone! \n"
}
4.2. bash-preexec.sh
This tiny but powerful script gives you preexec and precmd hooks in Bash — something Bash famously does not provide by default.
Example usage:
preexec() {
start_spinner &
SPINNER_PID=$!
}
precmd() {
stop_spinner
}
This integration is the “magic ingredient” that lets your spinner run before a command and stop right before the next prompt.
5. Publishing to GitHub
Please review my GitHub CLI installation guide here.
Step-by-step guide
- Create a repo:
gh repo create hhgttg-bash --public
- Add files:
git add .
git commit -m "Initial release of HHGTTG Bash module"
- Push to GitHub:
git push origin main
- Verify GitHub automatically displays your README.
- Celebrate with a cup of tea, preferably served by a polite robot.
6. Conclusion
Congratulations! The HHGTTG Bash module is now alive, published, and ready for other curious travelers of the command-line universe.
In the next post, we’ll discuss something equally important:
💥 Adding tests with BATS
💥 Testing your spinner, hooks, installer, and removal
💥 Ensuring nothing explodes (unless you intended it to)