@README.md
├── bin/ # Executable git commands (git-<name> pattern)
│ ├── git-* # Individual commands, invoked as `git <name>`
│ └── lib/ # Shared bash libraries
│ ├── common.sh # Core utilities (colors, error handling, git helpers)
│ ├── issue-tracking.sh # Issue tracker dispatcher (loads backends)
│ ├── linear.sh # Linear API backend
│ ├── vcs-hosting.sh # GitLab/GitHub abstraction layer
│ └── terminals.sh # Terminal detection utilities
├── config/ # Git configuration files
│ ├── main.gitconfig # Main entry point (includes all others)
│ ├── commands.gitconfig # Aliases for bin/git-* commands
│ ├── aliases.gitconfig # Short aliases (co, ci, st, etc.)
│ └── *.gitconfig # Other config modules (colors, diff, rebase, etc.)
├── Makefile # Lint and test commands
└── README.md # User-facing documentation
- Create executable script at
bin/git-<command-name> - Add shebang and source common library:
#!/usr/bin/env bash SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${SCRIPT_DIR}/lib/common.sh"
- Implement
usage()function that responds to-h/--help - Add alias in
config/commands.gitconfig:command-name = !~/.config/gitconfig/bin/git-command-name
- Document in
README.mdunder appropriate section
Scripts source libraries from bin/lib/:
source "${SCRIPT_DIR}/lib/common.sh" # Always first
source "${SCRIPT_DIR}/lib/issue-tracking.sh" # If needed
source "${SCRIPT_DIR}/lib/vcs-hosting.sh" # If neededKey functions from common.sh:
die "message"- Print error and exitwarn "message"- Print warning to stderrprint_red/green/yellow/bold- Colored outputrequire_git_repo- Exit if not in a git repoget_current_branch- Current branch name (works during rebase)is_main_branch "$branch"- Check if branch is master/mainfind_git_repos [dir]- Find all git repos under directory
After modifying any scripts, always run:
make lint # shellcheck validation
make test # bash syntax check
make test-help # verify --help works for all commandsWhen making changes, ensure these stay consistent:
| Change | Also update |
|---|---|
New bin/git-* command |
config/commands.gitconfig, README.md |
| New shared function | bin/lib/common.sh (or appropriate lib) |
| Rename/remove command | config/commands.gitconfig, README.md |
| Change command options | usage() in script, README.md |
| New library file | Document sourcing pattern in this file |
- All scripts use
set -euo pipefail(viacommon.sh) - Functions use
localfor all variables - Error messages go to stderr via
dieorwarn - Every command must handle
--helpflag - Use
require_git_repowhen command needs to be in a repo