Common functions for interactive Git demonstrations in the Git Hero project.
demo-utils.sh provides a consistent set of utilities for creating engaging, interactive Git demonstrations with typewriter effects, colored output, and user interaction controls.
Source the utilities in your demo script:
#!/bin/bash
# Load shared utilities
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/../../shared/demo-utils.sh"
# Use the functions
announce "🎯 Demo Title"
run "git status"
pauseDELAY_BETWEEN_CHARS- Delay between characters for typewriter effect (default: 0.09 seconds)AUTO_PAUSE- Enable/disable pauses (set tofalsewith--no-pauseflag)
--no-pause- Disable all pauses and typewriter effect for quick testing
Example:
./demo.sh --no-pauseDisplay text with character-by-character typewriter effect.
typewriter "git status"Execute a command with typewriter effect and optional pause.
run "git log --oneline" # Execute and pause
run "git checkout main" false # Execute without pausingWait for user input. Allows entering ad-hoc commands during demo.
pauseInteractive Feature: During a pause, users can type commands to explore further. The command will be executed and another pause will follow.
Display section header with yellow highlighting.
announce "🔍 1. Finding the Bug with Git Bisect"Display green success message with checkmark.
success "Setup complete!"Display blue informational message.
info "Current branch: main"Display yellow warning message.
warning "This will rewrite history!"Display red error message.
error "File not found"Display file contents with optional syntax highlighting (uses bat or pygmentize if available).
show_file "config.json"Display git diff with enhanced formatting (uses delta if available).
show_diff # Show unstaged changes
show_diff --staged # Show staged changes
show_diff main..feature # Show branch differencesDisplay formatted git log with graph.
git_log_pretty # Last 10 commits
git_log_pretty 20 # Last 20 commitsDisplay git status with informational header.
show_statusDisplay all branches with current branch highlighted.
show_branchesDisplay information about the current commit.
show_current_commitClear screen with optional header.
clear_screen
clear_screen "Git Bisect Demo"Display yes/no confirmation prompt.
if confirm "Continue with rebase?"; then
git rebase -i HEAD~5
fiDisplay horizontal separator line.
separatorDisplay text in a decorative box.
box "Git Hero" "Interactive Demonstrations" "NG Baguette Conf 2026"Start demo with title and description in a box.
start_demo "Git Bisect" "Find bugs automatically with binary search"End demo with summary and takeaways.
end_demo \
"Git bisect finds bugs in log2(n) steps" \
"Use 'git bisect run' for automated testing" \
"Always tag known-good versions"#!/bin/bash
# Load shared utilities
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/../../shared/demo-utils.sh"
# Start demo
start_demo "Git Reflog" "Recover 'lost' commits with Git's safety net"
# Section 1
announce "📋 1. Create Some Commits"
run "echo 'Hello' > file.txt"
run "git add . && git commit -m 'Add file'"
pause
# Section 2
announce "😱 2. Accidentally Delete Branch"
run "git branch -D experimental"
pause
# Section 3
announce "🔧 3. Recover with Reflog"
run "git reflog"
run "git checkout -b experimental-recovered HEAD@{1}"
pause
# End demo
end_demo \
"Reflog tracks all ref changes for 90 days" \
"Use git reflog to find 'lost' commits" \
"Git rarely loses data"| Function | Color | Icon |
|---|---|---|
success |
Green | ✅ |
info |
Blue | ℹ️ |
warning |
Yellow | |
error |
Red | ❌ |
announce |
Yellow | # |
run |
Green | $ |
- Bash 4.0+
- Git 2.30+
bat- Better syntax highlighting forshow_filedelta- Better diff display forshow_diffpygmentize- Alternative syntax highlighting
Functions gracefully degrade to standard commands if optional tools are not available.
- Start with announce - Begin each section with a clear header
- Use run for Git commands - Shows command before executing
- Pause strategically - Allow time for explanations and questions
- Add context - Use info/warning before complex operations
- End with takeaways - Summarize key learning points
- Test without pauses - Use
--no-pausefor quick validation
MIT
Part of Git Hero for NG Baguette Conf 2026