GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - phenonymous/shell-progressbar: An asynchronous progressbar for shell scripts

BranchesTags
Open more actions menu

Latest commit

 

History

84 Commits
84 Commits

Folders and files

NameName
Last commit message
Last commit date
images
images
 
 
COPYING
COPYING
 
 
README.md
README.md
 
 
progress.sh
progress.sh
 
 

Repository files navigation

shell-progressbar

A progressbar for shell scripts inspired by APT

Table of contents

  • Installation
  • Usage
    • Example
  • Customization

bar

For a POSIX compliant version see instructions in branch POSIX

Installation:

Put this anywhere in your script by using cURL

. <(curl -sLo- "https://git.io/progressbar")

or by using wget

. <(wget -qO- "https://git.io/progressbar")

Usage:

Make a call to

bar::start

before any progress should be reported. This will setup the status line by shrinking the terminal scroll area by one row. Then determine the total steps to be reported - either you're using this in a loop or do manual reporting in your script. What ever way suits your needs, make a call to

bar::status_changed <steps done> <total steps>

whenever progress is made. This function will then determine if the status line should be updated.

Finally make a call to

bar::stop

when you're done and this function will restore the terminal size.

Example

#!/usr/bin/env bash

. <(curl -sLo- "https://git.io/progressbar")

bar::start

StuffToDo=("Stuff1" "Stuff2" "Stuff3")

TotalSteps=${#StuffToDo[@]}

for Stuff in ${StuffToDo[@]}; do
  # Do stuff
  echo "Invoking ${Stuff} to do some stuffs..."
  StepsDone=$((${StepsDone:-0}+1))
  bar::status_changed $StepsDone $TotalSteps
  sleep 1
done

bar::stop

Customization

If you want to customize your progress string then change the following variables, shown below with defaults

LEFT_BRACKET=${LEFT_BRACKET:-"["}
RIGHT_BRACKET=${RIGHT_BRACKET:-"]"}
FILL=${FILL:-"#"}
REMAIN=${REMAIN:-"."}

You can change foreground and background color by setting these variables

foreground="$(tput setaf 0)" # black
background="$(tput setab 2)" # green

you can also tweak how often reporting should be done (in case of great number of steps and quick progressing) by setting reporting_steps to a value bigger than 1

About

An asynchronous progressbar for shell scripts

Topics

bashbsdcshfishfreebsdkshlinuxmacosxminixnetbsdopenbsdosxposixposix-compliantprogressprogress-barprogressbarshellsolariszsh

Resources

Readme
GPL-3.0 license
Activity

Stars

35 stars

Watchers

0 watching

Forks

6 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.