Personal automation scripts and Bash utilities for Linux/macOS workflows.
This repository contains a collection of Bash scripts for automation, development workflows, and system administration. It includes reusable Bash modules, technology-specific script libraries (Git, AWS, GCP, Terraform, Kubernetes, etc.), and AI-enhanced developer tools.
Public repository: https://github.com/grantcarthew/scripts
Installation via one-liner:
bash <(curl -s https://raw.githubusercontent.com/grantcarthew/scripts/main/install-scripts)Manual installation:
mkdir -p "${HOME}/bin"
cd "${HOME}/bin"
git clone git@github.com:grantcarthew/scripts.git
echo 'export PATH="${PATH}:${HOME}/bin/scripts"' >> "${HOME}/.bashrc"Add technology-specific libraries to PATH as needed:
echo 'export PATH="${PATH}:${HOME}/bin/scripts/lib/git"' >> "${HOME}/.bashrc"
echo 'export PATH="${PATH}:${HOME}/bin/scripts/lib/terraform"' >> "${HOME}/.bashrc"Bash Version: Bash 5.x required
Shebang: Always use #!/usr/bin/env bash
ShellCheck Compliance: All scripts MUST pass ShellCheck validation
- Configuration:
.shellcheckrcat repository root - External sources enabled for bash_modules
- Run:
shellcheck <script-name>
Variable Substitution:
- MUST use double-quotes and curly braces:
"${VARIABLE}" - When logging variable values, use single quotes around them:
log_message "Output: '${OUTPUT_FILE}'"
Test Constructs:
- Always use double square brackets:
[[ condition ]] - Never use single brackets or test command
Command Substitution:
- Always use
$()syntax - Never use backticks
Indentation: 2 spaces (no tabs)
Functions:
- Use
functionkeyword:function name() { ... } - Avoid single-use functions
- Keep main logic at root level
Comments:
- Minimal comments
- Code should be self-documenting
- Use clear variable and function names
Script Template:
- Use
templates/bash-templateas the starting point for new scripts - Includes proper error handling, logging setup, and validation patterns
Branch Management: Work on main branch (personal repository)
Commit Message Format: Conventional Commits style
type(scope): description
Examples:
feat(git): add new commit message generator
fix(aws): correct IAM policy lookup logic
docs(readme): update installation instructions
chore(config): update shellcheck rules
Before Committing:
- Run ShellCheck on modified scripts
- Test scripts in target environment
- Ensure executable permissions set:
chmod +x <script>
AI-Enhanced Scripts:
- Many scripts use AI for enhanced functionality (gcm, gdr, ucl, etc.)
- Prompt files stored alongside scripts with
-prompt.mdsuffix - See
ai/directory for role definitions and metaprompts
Key Directories:
-
bash_modules/: Reusable Bash function libraries (sourced modules)terminal.sh: Most common module withlog_*output functionsverify.sh: Input validation functionsutils.sh: General utility functionsai.sh,aws.sh,gcp.sh,git.sh: Technology-specific modules
-
lib/: Technology-focused executable scripts organized by domainlib/git/: Git workflow shortcuts (gcm, gdr, gig, ucl, etc.)lib/aws/: AWS CLI utilitieslib/gcp/: Google Cloud utilitieslib/terraform/: Terraform workflow toolslib/gitlab/: GitLab CI/CD helperslib/jira/: Jira CLI helpers- Each subdirectory has README.md with usage info
-
templates/: Script templates and project scaffoldingbash-template: Full-featured Bash script template with best practices- AI project templates
-
ai/: AI prompt collectionroles/: Domain-specific expert personascommands/: Task-oriented promptsmetaprompts/: Templates for creating promptstemplates/: Resume and cover letter templates
Unit Tests:
- Test files named with
-test.shsuffix inbash_modules/ - Run individual tests:
./<module>-test.sh
Manual Testing:
- Test scripts in isolated environments when possible
- Verify output using
log_*functions from terminal.sh - Check exit codes for proper error handling
ShellCheck Validation:
# Single file
shellcheck script-name
# All scripts in directory
find . -name "*.sh" -exec shellcheck {} \;
# Git pre-commit check
git diff --name-only --cached | grep '\.sh$' | xargs shellcheckScripts should source required modules from bash_modules/:
SCRIPT_DIR="$(cd "${BASH_SOURCE[0]%/*}" || exit 1; pwd)"
source "${SCRIPT_DIR}/bash_modules/terminal.sh"Common log functions (output to stderr):_*
log_title- Bold green title with double linelog_heading- Bold green heading with linelog_message- Normal messagelog_warning- Yellow warninglog_error- Red errorlog_success- Green checkmark messagelog_failure- Red cross message- See bash-template for full list
Core Tools Required:
- bash (v5.x)
- git
- curl
- shellcheck
Optional (based on script usage):
- ripgrep (rg) - Fast file searching
- fd - Modern file finder
- fzf - Fuzzy finder
- jq - JSON processor
- aichat - AI model CLI interaction
- lsd - Modern ls replacement
Cloud/Services (optional):
- aws - AWS CLI
- gcloud - Google Cloud CLI
- gh - GitHub CLI
- kubectl - Kubernetes CLI
See README.md for complete dependency list.
- Never commit sensitive tokens or credentials
- Use environment variables for authentication tokens
- Validate all user input using
verify.shmodule functions - Check file permissions before operations
- Scripts output to stderr via
log_*functions to avoid interfering with stdout
"terminal.sh module missing" error:
- Ensure bash_modules directory is accessible
- Check SCRIPT_DIR is correctly set
- Verify PATH includes repository root
ShellCheck warnings:
- Review
.shellcheckrcfor project-specific rules - External sources enabled for bash_modules
- Use proper quoting and variable expansion
Permission denied:
- Set executable:
chmod +x <script-name> - Check script ownership and directory permissions
AI-enhanced scripts not working:
- Ensure
aichatis installed and configured - Check AI model access tokens in environment
- Review corresponding
-prompt.mdfiles for requirements