Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eskerda/barsh
barsh - minimal bash progress bars
https://github.com/eskerda/barsh
bash
Last synced: 23 days ago
JSON representation
barsh - minimal bash progress bars
- Host: GitHub
- URL: https://github.com/eskerda/barsh
- Owner: eskerda
- License: mit
- Created: 2021-05-20T09:22:52.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-12T09:25:48.000Z (about 2 years ago)
- Last Synced: 2024-10-04T21:38:48.390Z (about 1 month ago)
- Topics: bash
- Language: Shell
- Homepage:
- Size: 1.95 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# barsh: a minimal bash progress bar
barsh is a 7-lines implementation of a progress bar in bash, using bg/fg color
ANSI escape sequences instead of block characters. Use it directly as a
standalone tool on your shell, source it and use it on your scripts, or just
admire it in all its glory```bash
function barsh {
[[ $# -lt 2 ]] && return 1
local val=$1; local bas=$2; local txt=$3; local wid=$4;[[ -z $wid ]] && { [[ -z $txt ]] && wid=$bas || wid=${#txt} ; }
[[ -z $txt ]] && txt="$(printf '%*s' "$wid" '')"
[[ $wid -gt ${#txt} ]] && txt=$txt$(printf '%*s' $((${#txt} - wid)) '')local per=$(( (wid * val) / bas ))
printf "\033[7m%s\033[27m%s" "${txt:0:$per}" "${txt:$per:$((wid-per))}"
}
```## Usage demo
```bash
$ curl https://raw.githubusercontent.com/eskerda/barsh/master/barsh.sh | bash
```