{"id":17349028,"url":"https://github.com/nafigator/bash-helpers","last_synced_at":"2025-04-14T20:50:55.001Z","repository":{"id":41274804,"uuid":"102687985","full_name":"nafigator/bash-helpers","owner":"nafigator","description":"Collections of handly functions for usage in Bash scripts","archived":false,"fork":false,"pushed_at":"2024-11-19T03:42:31.000Z","size":424,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T09:04:11.372Z","etag":null,"topics":["bash","bash-script","includes"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"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/nafigator.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}},"created_at":"2017-09-07T03:40:44.000Z","updated_at":"2025-01-19T12:44:56.000Z","dependencies_parsed_at":"2024-06-11T04:48:04.165Z","dependency_job_id":"51ed1a04-05f8-4df3-a512-2fc858792e33","html_url":"https://github.com/nafigator/bash-helpers","commit_stats":{"total_commits":85,"total_committers":1,"mean_commits":85.0,"dds":0.0,"last_synced_commit":"204602d608eebb5d57b90eea8ab49b1375acbc6f"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nafigator%2Fbash-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nafigator%2Fbash-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nafigator%2Fbash-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nafigator%2Fbash-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nafigator","download_url":"https://codeload.github.com/nafigator/bash-helpers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248757368,"owners_count":21156930,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","bash-script","includes"],"created_at":"2024-10-15T16:54:25.253Z","updated_at":"2025-04-14T20:50:54.993Z","avatar_url":"https://github.com/nafigator.png","language":"Shell","readme":"[![GitHub license][License img]][License src] [![GitHub release][Release img]][Release src] [![Conventional Commits][Conventional commits badge]][Conventional commits src] [![Semantic Versioning][Versioning img]][Versioning src]\n# bash-helpers\n**Collection of useful functions for usage in Bash scripts**\n\n## Usage\n\n#### Without installation\n\n\t#!/usr/bin/env bash\n\n\tsource \u003c(curl -s https://raw.githubusercontent.com/nafigator/bash-helpers/1.1.1/src/bash-helpers.sh)\n\t\n#### With installation\n1. Put bash libs into `/usr/local/lib/bash/includes` dir.\n2. Source `bash-helpers.sh` in executable script:\n\t```bash\n\t. /usr/local/lib/bash/includes/bash-helpers.sh\n\t```\n\n## Installation (optional)\n\n\t[ -d /usr/local/lib/bash/includes ] || sudo mkdir -p /usr/local/lib/bash/includes\n\tsudo curl -o /usr/local/lib/bash/includes/bash-helpers.sh https://raw.githubusercontent.com/nafigator/bash-helpers/master/src/bash-helpers.sh\n\tsudo chmod +x /usr/local/lib/bash/includes/bash-helpers.sh\n\n#### Install functions examples\n\n\t#!/usr/bin/env bash\n\n\tdownload_bash_helpers() {\n\t\tprintf \"Installing bash-helpers\\n\"\n\t\t[[ ! -d /usr/local/lib/bash/includes ]] || sudo mkdir -p /usr/local/lib/bash/includes\n\n\t\tsudo curl -so /usr/local/lib/bash/includes/bash-helpers.sh https://raw.githubusercontent.com/nafigator/bash-helpers/master/src/bash-helpers.sh\n\t\tsudo chmod +x /usr/local/lib/bash/includes/bash-helpers.sh\n\n\t\treturn 0\n\t}\n\n\tinit_bash_helpers() {\n\t\t[[ -e /usr/local/lib/bash/includes/bash-helpers.sh ]] || download_bash_helpers\n\n\t\tif [[ ! -x /usr/local/lib/bash/includes/bash-helpers.sh ]]; then\n\t\t\tprintf \"Insufficient permissions for bash-helpers execute\\n\"; return 1\n\t\tfi\n\n\t\t. /usr/local/lib/bash/includes/bash-helpers.sh\n\n\t\treturn 0\n\t}\n\n\tinit_bash_helpers || exit 1\n\n\n## Composer installation\n\n\tcomposer require nafigator/bash-helpers\n\n## Features:\n* **Defines human-readable functions for colors and formatting:**\n\t- black()\n\t- red()\n\t- green()\n\t- yellow()\n\t- blue()\n\t- magenta()\n\t- cyan()\n\t- white()\n\t- gray()\n\t- bold()\n\t- clr()\n\n\tExamples:\n\t```bash\n\tprintf \"$(bold)$(red)ATTENTION$(clr) Save $(cyan)failure$(clr)\"\n\t```\n\t![Colors definition][Colors definition img]\n\t\u003e **NOTE**: For logging purpose colors may be disabled by global `INTERACTIVE` variable:\n\t\u003e\n\t\u003eINTERACTIVE=\n* **Functions for nicely formatted messages `error`, `inform`, `warning`.**\n\n\tExamples:\n\t```bash\n\tinform 'Script start'\n\twarning 'Make backup!'\n\terror 'File not found'\n\t```\n\t![Messages formatting][Messages formatting img]\n* **Libs including.**\n\n\tExample:\n\t```bash\n\tinclude google/client || exit 1\n\tinclude mysql/query-builder || exit 1\n\tinclude logger; status 'Logger including' $? || exit 1\n\t```\n* **Status messages.**\n\n\tExample:\n\t```bash\n\ttest -d /usr/local/nonexistent\n\tstatus 'Check /usr/local/nonexistent dir' $?\n\ttest -d /usr/local/bin\n\tstatus 'Check /usr/local/bin dir' $?\n\t```\n\t![Status messages][Status messages img]\n* **Checking dependencies.**\n\n\tExample:\n\t```bash\n\tcheck_dependencies yarn rust || exit 1\n\t```\n\t![Check dependencies][Check dependencies img]\n* **Debug messages and statuses.**\n\n\tExample:\n\t```bash\n\tdebug 'This message is hidden'\n\tstatus_dbg 'This status is hidden' $?\n\tDEBUG=1\n\tdebug 'Visible because of DEBUG variable'\n\ttest -d /nonexists\n\tstatus_dbg 'Visible because of DEBUG variable' $?\n\ttest -d /var/log\n\tstatus_dbg 'Visible because of DEBUG variable' $?\n\t```\n\t![Debug messages][Debug messages img]\n\n## Message statuses\n\n\t[ OK ] - success status\n\t[FAIL] - fail status\n\t[ ?? ] - debug message\n\t[ ++ ] - success debug status\n\t[ -- ] - fail debug status\n\n## Versioning\nThis software follows *\"Semantic Versioning\"* specifications. All function signatures declared as public API.\n\nRead more on [SemVer.org](http://semver.org).\n\n[Conventional commits src]: https://conventionalcommits.org\n[Conventional commits badge]: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg\n[Release img]: https://img.shields.io/github/v/tag/nafigator/bash-helpers?logo=github\u0026labelColor=333\u0026color=teal\n[Release src]: https://github.com/nafigator/bash-helpers\n[License img]: https://img.shields.io/github/license/nafigator/bash-helpers?logoColor=333\u0026color=teal\n[License src]: https://tldrlegal.com/license/mit-license\n[Versioning img]: https://img.shields.io/badge/Semantic%20Versioning-2.0.0-teal.svg\n[Versioning src]: https://semver.org\n[Colors definition img]: https://raw.githubusercontent.com/nafigator/bash-helpers/master/.images/colors-definition.jpg\n[Messages formatting img]: https://raw.githubusercontent.com/nafigator/bash-helpers/master/.images/messages-formatting.jpg\n[Status messages img]: https://raw.githubusercontent.com/nafigator/bash-helpers/master/.images/status-messages.jpg\n[Check dependencies img]: https://raw.githubusercontent.com/nafigator/bash-helpers/master/.images/check-dependencies.jpg\n[Debug messages img]: https://raw.githubusercontent.com/nafigator/bash-helpers/master/.images/debug-messages.jpg\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnafigator%2Fbash-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnafigator%2Fbash-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnafigator%2Fbash-helpers/lists"}