{"id":41619869,"url":"https://github.com/waltlenu/shlib","last_synced_at":"2026-04-06T18:02:08.826Z","repository":{"id":333312518,"uuid":"1136854240","full_name":"waltlenu/shlib","owner":"waltlenu","description":"BASH functions","archived":false,"fork":false,"pushed_at":"2026-02-01T18:26:20.000Z","size":275,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-01T21:12:49.107Z","etag":null,"topics":["bash","shell","terminal"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/waltlenu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-18T13:37:58.000Z","updated_at":"2026-02-01T17:49:31.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/waltlenu/shlib","commit_stats":null,"previous_names":["waltlenu/shlib"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/waltlenu/shlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waltlenu%2Fshlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waltlenu%2Fshlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waltlenu%2Fshlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waltlenu%2Fshlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/waltlenu","download_url":"https://codeload.github.com/waltlenu/shlib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waltlenu%2Fshlib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31483380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T17:22:55.647Z","status":"ssl_error","status_checked_at":"2026-04-06T17:22:54.741Z","response_time":112,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","shell","terminal"],"created_at":"2026-01-24T13:30:44.923Z","updated_at":"2026-04-06T18:02:08.817Z","avatar_url":"https://github.com/waltlenu.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# shlib\n\n[![CI](https://github.com/waltlenu/shlib/actions/workflows/ci.yml/badge.svg)](https://github.com/waltlenu/shlib/actions/workflows/ci.yml)\n\nA library of reusable [Bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell)) shell functions.\n\n- Just [one file](shlib.bash), but a long one 😜 -\u003e easy to download and source\n- Pure Bash:\n  - Idiomatic\n  - No external binaries[^1]\n  - Bash `\u003e= 3.x`, or `4`[^2][^3]\n- Won't pollute the environment\n  - Every function is \"name-spaced\" by prefixing it with `shlib::`\n  - Every global variable is \"name-spaced\" by prefixing it with `SHLIB_`\n- Strict mode (`set -euo pipefail`) enabled\n- Fully tested with [bats](https://github.com/bats-core/bats-core)\n- Statically analysed with [ShellCheck](https://github.com/koalaman/shellcheck)\n- Yes, I let [Claude Code](CLAUDE.md) assist me but I watch it with suspicion 👹\n\n[^1]: Whenever possible\n[^2]: There is a section called KV (Key Value) that implements associative arrays functions. It requires BASH v4.x+.\n[^3]: Because that's what MacOS ships with (the last version released under GPL2)\n\n## Usage\n\n_**Don't** just \"curl pipe bash it\"_\n\n⚠️ First, **please read** the [code](shlib.bash), at least the top of the file.\n\nThat's where all the global instructions/variables are located. The rest of the file is made up Bash function definitions. Everything _should_ be inoffensive because I don't want errors in my own scripts, but **don't** take my word for it.\n\nI recommend downloading the latest [released](https://github.com/waltlenu/shlib/releases) version of this library and source in your Bash script:\n\n```bash\n#!/usr/bin/env bash\n\nREMOTE='waltlenu/shlib'\nLATEST_TAG=$(curl -sL \"https://api.github.com/repos/$REMOTE/releases/latest\" \\\n  | grep '\"tag_name\":' | sed -E 's/.*\"([^\"]+)\".*/\\1/')\ncurl -fsSL --remote-name \\\n  \"https://raw.githubusercontent.com/$REMOTE/refs/tags/$LATEST_TAG/shlib.bash\"\n\n# Load library\nsource shlib.bash\n\n# Use library functions\nshlib::einfon \"Hello 🌍\"\n```\n\nBut if you prefer the very [latest](https://raw.githubusercontent.com/waltlenu/shlib/refs/heads/main/shlib.bash), or just copy a function, go ahead.\n\n### Examples\n\nTry running the [examples/usage.sh](examples/usage.sh) script. The `shlib::ansi_` functions print pretty colors 😀\n\n### Documentation\n\nRead the man page(s):\n\n```bash\nman ./shlib.7\n```\n\n## Contributing\n\n### Project Structure\n\n```text\nshlib/\n├── shlib.bash          # THE library\n├── shlib.7             # Man page\n├── shlib.bats          # Bats tests\n├── shlib.example.bash  # Usage example\n|\n├── hack/               # Building scripts\n├── src/                # Codebase fragments\n└── tmpl/               # Template files\n```\n\n### Adding New Functions\n\nInsert/Append functions to `shlib.bash` by adding files to `src/` and making sure you add the `shlib::` namespace prefix:\n\n```bash\nshlib::my_function() {\n    # implementation\n}\n```\n\n### Linting, formatting, testing\n\nThis project uses:\n- [ShellCheck](https://github.com/koalaman/shellcheck) for static analysis\n- [shfmt](https://github.com/patrickvane/shfmt) for formatting\n- [Bats](https://github.com/bats-core/bats-core) for testing\n\n```bash\nmake all\n\n# or:\nshellcheck -s bash shlib.bash\nshfmt -i 4 -ci -bn shlib.bash\nbats tests/\n```\n\n### TODO\n\nPlenty of features still missing:\n\n- [ ] ui: add a confirmation prompt\n- [ ] sys: add functions like is_root\n- [ ] make tmp file, dir\n- [ ] random string functions\n\n## License\n\nMIT License - see [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaltlenu%2Fshlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwaltlenu%2Fshlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaltlenu%2Fshlib/lists"}