Skip to content

Comprehensive tool designed to ensure your Bash scripts run smoothly across different environments by managing system commands and package dependencies. It supports a variety of package managers across Linux distributions and macOS.

Notifications You must be signed in to change notification settings

shadowdevnotreal/Bash-buddy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

file-qG7xJYxXVw5KuElGjeBdXBhf

πŸ› οΈ BashBuddy

Cross-Platform Dependency Management for Bash Scripts

License Bash Platform

Never worry about missing dependencies again!

BashBuddy automatically detects your system, checks for required commands, and installs missing packages across any platform.

Features β€’ Installation β€’ Usage β€’ Documentation


✨ Features

πŸ” Smart Detection

  • Automatic OS and package manager detection
  • Cross-platform support out of the box
  • Intelligent fallback mechanisms

πŸ”’ Safe & Reliable

  • Strict error handling (set -euo pipefail)
  • User confirmation before installations
  • Post-installation verification

πŸ“¦ Wide Compatibility

  • Linux: apt, dnf, yum, pacman
  • macOS: brew
  • Windows: choco, scoop, MSYS2, WSL

🎯 Developer Friendly

  • Template-based skeleton script
  • Easy to customize for your project
  • Comprehensive inline documentation

🌍 Platform Support

Platform Package Managers Status
🐧 Linux apt, dnf, yum, pacman βœ… Full Support
🍎 macOS Homebrew (brew) βœ… Full Support
πŸͺŸ Windows Chocolatey, Scoop, MSYS2 βœ… Full Support
🐧 WSL apt (Ubuntu/Debian) βœ… Full Support
πŸ”§ Cygwin Auto-detection βœ… Supported

πŸ’– Support FOSS Development

Buy Me A Book

πŸ“š Overview of BashBuddy Scripts

BashBuddy provides three scripts tailored for different use cases:

Script Purpose Use Case
bashbuddy.sh πŸ—οΈ Main Skeleton Template for your own projects. Copy and customize the dependency list for your needs.
full_sample.sh 🎯 Working Example Full-featured implementation with extended package mappings. Use as a reference or standalone tool.
sim_sample.sh πŸŽ“ Educational Demo Safe simulation that shows how mappings work without installing anything.

πŸ“– Documentation

For detailed usage instructions, advanced features, and best practices, visit our:

πŸ“˜ Wiki Page β€” Comprehensive guides and tutorials


πŸš€ Installation

Quick Start

# 1. Clone the repository
git clone https://github.com/shadowdevnotreal/Bash-buddy.git

# 2. Navigate to the directory
cd Bash-buddy

# 3. Make scripts executable
chmod +x *.sh

Single Command Installation

curl -fsSL https://raw.githubusercontent.com/shadowdevnotreal/Bash-buddy/main/full_sample.sh | bash

πŸ’» Usage

πŸ—οΈ Using the Skeleton Script (For Your Projects)

The skeleton script is designed to be copied into your own projects and customized:

# Run with default dependencies (curl, wget, tar)
./bashbuddy.sh

To customize for your project:

  1. Open bashbuddy.sh in your editor
  2. Modify the command_to_package array on line 21:
declare -A command_to_package=(
    [git]="git"
    [docker]="docker"
    [python3]="python3"
    # Add your dependencies here
)
  1. Update the required_commands array in the main() function (line 209)

🎯 Using the Full Sample (Standalone Tool)

The full sample accepts commands as arguments and installs them:

# Check and install specific tools
./full_sample.sh git nvim htop

# Check multiple dependencies at once
./full_sample.sh curl wget docker nodejs python3

Example Output:

BashBuddy - Checking dependencies...
Detected WSL (Windows Subsystem for Linux)
Missing commands: nvim htop
Do you want to proceed with the installation? (y/N) y
Updating package index...
Attempting to install 'neovim' for command 'nvim'...
βœ“ Successfully installed all missing packages!
All required commands are now available.

πŸŽ“ Exploring with Simulation

Safe demonstration without installing anything:

./sim_sample.sh

This displays how command-to-package mappings work without making system changes.


🎯 Use Cases

For Script Authors

#!/bin/bash
# your-awesome-script.sh

# Source BashBuddy at the start of your script
source ./bashbuddy.sh

# Your script logic here - all dependencies guaranteed!
curl https://api.example.com/data | jq '.results'

For DevOps & CI/CD

# .github/workflows/build.yml
- name: Install dependencies
  run: ./full_sample.sh make gcc docker

For Development Environments

# Setup script for your team
./full_sample.sh git node python3 docker

🀝 Contributing

We love contributions! Here's how you can help:

Ways to Contribute

  • πŸ› Report bugs β€” Open an issue with details
  • πŸ’‘ Suggest features β€” We're always looking for ideas
  • πŸ“ Improve docs β€” Help others understand BashBuddy better
  • πŸ”§ Submit PRs β€” Add support for new package managers

Contribution Workflow

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/AmazingFeature
  3. Commit your changes
    git commit -m 'Add AmazingFeature'
  4. Push to your branch
    git push origin feature/AmazingFeature
  5. Open a Pull Request

πŸ”§ Troubleshooting

Script fails with "Unsupported package manager"

Make sure you have a supported package manager installed:

Permission denied errors

Make sure the scripts are executable:

chmod +x bashbuddy.sh full_sample.sh sim_sample.sh
WSL not detected correctly

If you're on WSL but detection fails, check that /proc/version exists and contains "microsoft" or "WSL":

cat /proc/version
Package installation fails

Common causes:

  • Update your package manager index first (e.g., sudo apt update)
  • Check your internet connection
  • Verify you have sudo permissions (for Linux package managers)
  • Check if the package name is correct for your distro

πŸ“‹ FAQ

Q: Can I use this in production scripts? A: Absolutely! BashBuddy uses strict error handling and is designed for production use.

Q: Does it require root/sudo access? A: Only for installing packages with system package managers (apt, dnf, yum, pacman). Homebrew, Scoop, and user-level installs don't require sudo.

Q: Can I add custom package sources/PPAs? A: Yes! Extend the install_packages() function to add custom repositories before installation.

Q: What if a command has different package names across distros? A: Use the get_package_name() function pattern from full_sample.sh to map commands to distro-specific packages.


πŸ“„ License

This project is open source and available under the MIT License.


🌟 Show Your Support

If BashBuddy helped you, consider:

  • ⭐ Starring this repository
  • 🐦 Sharing with your network
  • β˜• Buying me a coffee (button at the top)

Made with ❀️ for the open source community

Report Bug β€’ Request Feature β€’ Wiki

About

Comprehensive tool designed to ensure your Bash scripts run smoothly across different environments by managing system commands and package dependencies. It supports a variety of package managers across Linux distributions and macOS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages