beddu.sh - A lightweight bash framework for interactive scripts and pretty output
  • Shell 87.4%
  • Makefile 12.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Manuele Sarfatti 8bbb2b76a1
Some checks failed
Test / macos-latest (push) Has been cancelled
Test / ubuntu-latest (push) Has been cancelled
Test / bash 4.3 (push) Has been cancelled
style: Format release notes script
2026-10-22 20:19:30 +02:00
.github/workflows test: Add test suite and CI workflow 2026-10-18 16:30:48 +02:00
demo docs: Add demo SVG to README 2026-10-18 17:00:31 +02:00
dist Release v1.3.1 2026-10-18 17:16:24 +02:00
scripts style: Format release notes script 2026-10-22 20:19:30 +02:00
src fix: Show the cursor at exit and keep caller traps 2026-10-18 16:31:52 +02:00
test fix: Show the cursor at exit and keep caller traps 2026-10-18 16:31:52 +02:00
.editorconfig Apply editorconfig rules to all files 2026-10-18 15:53:09 +02:00
.gitignore chore: Add .gitignore 2026-10-18 14:49:36 +00:00
AGENTS.md build: Group release notes by change type 2026-10-18 17:14:28 +02:00
CLAUDE.md docs: Add AGENTS.md guidance and CLAUDE.md 2026-10-18 16:32:55 +02:00
LICENSE Initial commit - v1.0 2025-05-09 20:01:43 +02:00
Makefile build: Group release notes by change type 2026-10-18 17:14:28 +02:00
README.md Release v1.3.1 2026-10-18 17:16:24 +02:00

Beddu 💅🏻

A lightweight bash framework for interactive scripts with pretty output.

Overview

Beddu is a minimalist bash library that makes your terminal scripts more interactive and visually appealing. It provides easy-to-use and intuitive functions for colorful text, spinners, progress indicators, and user interaction.

Your scripts will look something like this:

Example

And you will easily be able to build things like:

asciicast demo

Features

  • Text Formatting: Bold, italic, underline and more
  • Color Support: Basic colors and full ANSI 256 color support
  • User Interaction: Ask for input, confirmations, and present menu choices
  • Visual Indicators: Spinners, checkmarks, and error symbols
  • Line Manipulation: Replace previous output for dynamic updates

Installation and Usage

Beddu is meant to be sourced in your own script.

  1. Download the latest release (currently: v1.3.1) of beddu.sh to your project:
$ curl -O https://raw.githubusercontent.com/mjsarfatti/beddu/refs/tags/v1.3.1/dist/beddu.sh
  1. Source the beddu.sh file in your script:
#!/usr/bin/env bash
source "/path/to/beddu.sh"

# Now use beddu functions
pen bold blue "Hello, world!"

Demo

To see it in action, clone the repository, then run make demo. This will run the same interactive demo that you can see in the video above (please note that a 12MB wikimedia.org random file will be downloaded during the demo to showcase the functionality - a prompt will let you delete it at the end):

$ git clone https://github.com/mjsarfatti/beddu.git
$ make demo

Examples

More can be seen by looking at the demo file, but here is a quick overview:

Text Formatting and Colors

# Basic formatting
pen bold "Bold text"
pen italic "Italic text"
pen underline "Underlined text"

# Colors
pen red "Red text"
pen green "Green text"
pen 39 "ANSI color code 39 (light blue)"

# Combined
pen bold red "Bold red text"

# Inline
pen "This is $(pen yellow "yellow"), and this is $(pen bold "bold")"

Interactive Functions

# Kindly ask for input (empty answer is accepted)
seek name "What's your name?"
pen "Hello, $name!"

# Firmly ask for input (empty answer NOT accepted)
request name "No really, what's your name?"
pen "There you go, $name!"


# Yes/no confirmation (defaults to "yes")
if confirm "Continue?"; then
    pen green "Continuing..."
else
    pen red "Aborting."
fi

# Defaulting to "no"
if confirm --default-no "Are you sure?"; then
    pen green "Proceeding..."
else
    pen red "Cancelled."
fi

# Menu selection
choose color "Select a color:" "Red" "Green" "Blue"
pen "You selected: $color"

Progress Indicators

# Show a progress spinner
spin "Working on it..."
sleep 2
check "Done!" # Automatically stops and replaces the spinner

# Replace lines dynamically
pen "This will be replaced..."
sleep 1
repen "Processing started..."
sleep 1
repen spin "Almost done..." # Let's add a spinner for good measure
sleep 1
check "Task completed!" # We can directly `check`, `warn`, or `throw` after a `spin` call - the message will always replace the spin line

Function Reference

Text Formatting

  • pen [OPTIONS] TEXT - Output formatted text
    • -n - No newline after output
    • bold, italic, underline - Text styles
    • black, red, green, yellow, blue, purple, cyan, white, grey, gray - Color names
    • 0-255 - ANSI color codes

User Interaction

  • seek [retval] PROMPT - Get (optional) text input from user, saves the answer in $retval
  • request [retval] PROMPT - Like above, but doesn't accept an empty response, saves the answer in $retval
  • confirm [OPTIONS] PROMPT - Get yes/no input
    • --default-yes - Set default answer to "yes" (default behavior)
    • --default-no - Set default answer to "no"
  • choose [retval] PROMPT [OPTIONS...] - Display a selection menu, saves the answer in $retval

Progress Indicators

  • spin MESSAGE - Show an animated spinner
  • check MESSAGE - Show a success message (if called right after a spinner, it stops and replaces it)
  • warn MESSAGE - Show a warning message (if called right after a spinner, it stops and replaces it)
  • throw MESSAGE - Show an error message (if called right after a spinner, it stops and replaces it)
  • repen [OPTIONS] MESSAGE - Like pen, but replace the previous line (it accepts all the same options)

Advanced

Beddu hides the cursor in some of the functions. It then sets EXIT, INT and TERM traps that show the cursor again when your script stops (even unexpectedly). These traps keep your own traps and run them. If you set a trap after Beddu hid the cursor, your trap replaces the Beddu trap, so make sure that your trap shows the cursor (show_cursor), or set your traps before you use Beddu.

FAQ

Q: It doesn't work on my computer?

A: Beddu requires bash v4.3+. If you are on a mac, you probably want to brew install bash. If your bash version checks out, please file an issue!

Q: Can you add feature X?

A: Most likely, not (but never say never). This is meant to be a minimal toolkit to quickly jot down simple interactive scripts, nothing more. If you are looking for something more complete check out Gum (bash), Inquire (Rust), Enquirer (Node) or Awesome Bash.

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.