https://github.com/kndndrj/shload
Loading bar for your shell scripts!
https://github.com/kndndrj/shload
Last synced: 3 months ago
JSON representation
Loading bar for your shell scripts!
- Host: GitHub
- URL: https://github.com/kndndrj/shload
- Owner: kndndrj
- License: mit
- Created: 2021-05-04T16:23:04.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-03T06:49:07.000Z (about 1 year ago)
- Last Synced: 2025-04-15T02:44:48.219Z (6 months ago)
- Language: Shell
- Homepage:
- Size: 19.5 KB
- Stars: 55
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shload - Shell Loading Bar
I created this simple loading bar because I found it useful to have a kind of progress tracking in some scripts.
```
Progress: [=== ] 27%
Progress: [++++++++++++++++++++++++] 100%
Progress: [---------------------------- ] 56%
```
The main (and possibly only) design decision was for the script to be POSIX compliant and to have the setup function do as much work as possible (thats why the resizing doesn't work while running).## Usage
This bar consists of 2 simple shell functions; `shload_setup()` and `shload_update()`. The first function sets up the bar with max count, width and other presets and it is also used to calculate the width of the bar.To use **shload**, copy these functions from `shload.sh` to your script and use them like so:
1. Initiate the bar with the maximum number and a loading symbol (string):
```sh
shload_setup
```
2. Call the update function for every iteration following up to the maximum number:
```sh
while read file; do
#...some work...shload_update
done
```
It's best to keep the forementioned functions as close as possible, so you don't print something over the bar.## Example
You can find an example in `shexample.sh`. If you run the script by itself, you should see the progress bar in action:
```sh
./shexample.sh
```
Peek inside the mentioned files to take a deeper look at the example. Also, try resizing the terminal window before running the script