{"id":17984414,"url":"https://github.com/adoyle-h/shell-general-colors","last_synced_at":"2025-03-25T20:32:03.637Z","repository":{"id":149887852,"uuid":"191607522","full_name":"adoyle-h/shell-general-colors","owner":"adoyle-h","description":"A script to generate sets of shell variables (ANSI escape sequences) to control text color, boldness, underlining, blinking and other effects.","archived":false,"fork":false,"pushed_at":"2023-02-13T13:50:13.000Z","size":29,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-20T17:51:41.695Z","etag":null,"topics":["ansi","bash","color","shell","shell-color","terminal"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adoyle-h.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},"funding":{"patreon":"adoyle_h","liberapay":"adoyle","custom":["https://media.githubusercontent.com/media/adoyle-h/_imgs/master/sponsor.png"]}},"created_at":"2019-06-12T16:27:10.000Z","updated_at":"2024-06-13T19:02:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"4e0b41c9-b027-4ffc-ba8e-3f0581e5a9ee","html_url":"https://github.com/adoyle-h/shell-general-colors","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoyle-h%2Fshell-general-colors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoyle-h%2Fshell-general-colors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoyle-h%2Fshell-general-colors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoyle-h%2Fshell-general-colors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adoyle-h","download_url":"https://codeload.github.com/adoyle-h/shell-general-colors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245540345,"owners_count":20632144,"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":["ansi","bash","color","shell","shell-color","terminal"],"created_at":"2024-10-29T18:21:18.074Z","updated_at":"2025-03-25T20:32:03.560Z","avatar_url":"https://github.com/adoyle-h.png","language":"Shell","funding_links":["https://patreon.com/adoyle_h","https://liberapay.com/adoyle","https://media.githubusercontent.com/media/adoyle-h/_imgs/master/sponsor.png"],"categories":[],"sub_categories":[],"readme":"# Shell General Colors\n\nA script to generate sets of shell variables (ANSI escape sequences) to control text color, boldness, underlining, blinking and other effects.\n\nSupport general colors: `BLACK` `RED` `GREEN` `YELLOW` `BLUE` `PURPLE` `CYAN` `WHITE` `GREY`.\n\nNot support custom RGB color. [ansi][] is a good choice.\n\nThe difference between ansi and Shell General Colors is usability.\nShell General Colors provides simple variables which aim to be fast in runtime while ansi provides flexible functions.\n\n## Preview\n\nSee [Usage](#usage) and run `./test` to preview.\n\n## Versioning\n\nRead [tags][] for verions.\nThe versions follow the rules of [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html).\n\n## Installation\n\n```sh\n# Clone this repo\ngit clone --depth 1 https://github.com/adoyle-h/shell-general-colors.git\n# Copy it to somewhere in your path\nsudo ln -s \"$PWD/generate\" /usr/local/bin/shell-general-colors\n```\n\n## Usage\n\nThere are two ways to generate colors: list or map.\n\n### Color List\n\n#### Generate Color List\n\nFirst, generate a colors.bash file to your project.\n\n```sh\n# cd to your project\n# \"shell-general-colors -h\" to get usage\nshell-general-colors\n# Generated file: colors.bash\n```\n\nThe generated file \"colors.bash\" will contain below codes.\n\n```sh\n# General Foreground Colors\nBLACK='\\e[30m'\nRED='\\e[31m'\nGREEN='\\e[32m'\nYELLOW='\\e[33m'\nBLUE='\\e[34m'\nPURPLE='\\e[35m'\nCYAN='\\e[36m'\nWHITE='\\e[37m'\nGREY='\\e[90m'\n\n# ...\n\n# RESET\nRESET_FG='\\e[39m'\nRESET_BG='\\e[49m'\nRESET_ALL='\\e[0m'\n```\n\n#### Use Color List\n\nThen source the colors.bash file and use these variables directly.\n\n```sh\nsource \u003cpath\u003e/colors.bash\n\necho -e \"this is ${RED}red${RESET_ALL}. this is ${YELLOW}yellow${RESET_ALL}.\"\nprintf 'this is %bblue%b.' \"${BLUE}\" \"${RESET_ALL}\"\n```\n\nIf you want to use color variables with [here documents][]. Use [escaped variables](#export-escaped-variables).\n\n### Color Map\n\n#### Generate Color Map\n\nFirst, generate a colors.bash file to your project.\n\n```sh\n# cd to your project\n# \"shell-general-colors -h\" to get usage\nshell-general-colors --map\n# Generated file: colors.bash\n```\n\n**Notice**: When use `--map` option and specific output, you must pass `--` before output path.\n\n```sh\nshell-general-colors --map -- colors.bash\n```\n\nThe generated file \"colors.bash\" will contain below codes.\n\n```sh\ndeclare -g -A colors=(\n\n  # General Foreground Colors\n  [BLACK]='\\e[30m'\n  [RED]='\\e[31m'\n  [GREEN]='\\e[32m'\n  [YELLOW]='\\e[33m'\n  [BLUE]='\\e[34m'\n  [PURPLE]='\\e[35m'\n  [CYAN]='\\e[36m'\n  [WHITE]='\\e[37m'\n  [GREY]='\\e[90m'\n\n  # ...\n\n  # RESET\n  [RESET_FG]='\\e[39m'\n  [RESET_BG]='\\e[49m'\n  [RESET_ALL]='\\e[0m'\n)\n```\n\n#### Use Color Map\n\nThen source the colors.bash file and use these variables directly.\n\n```sh\nsource \u003cpath\u003e/colors.bash\n\nRESET_ALL=${colors[RESET_ALL]}\ncolor1=RED\ncolor2=YELLOW\ncolor3=BLUE\n\necho -e \"this is ${colors[color1]}red${RESET_ALL}. this is ${colors[color2]}yellow${RESET_ALL}.\"\nprintf 'this is %bblue%b.' \"${colors[color3]}\" \"${RESET_ALL}\"\n```\n\nIf you want to use color variables with [here documents][]. Use [escaped variables](#export-escaped-variables).\n\n## Advanced Usage\n\n### Change generated file path\n\n```sh\nshell-general-colors \"~/colors.bash\"\n# $output generated\n```\n\n### Force write\n\nThe script checks existed file by default. You can force write file with `-y` option.\n\n```sh\nshell-general-colors -y\n# $output generated\n```\n\n### Set variable prefix\n\nIf `-p=\u003cprefix\u003e` set, Add prefix `\u003cprefix\u003e` to each name of exported variables.\n\n```sh\nshell-general-colors -p C_\n# C_BLACK, C_RED, C_BOLD_BLACK ...\n```\n\n### Export escaped variables\n\nIf `-e` set, export escaped variables instead of general variables. \n\nIf `-e=\u003cescaped_suffix\u003e` set, export escaped variables instead of general variables. And add suffix `\u003cescaped_suffix\u003e` to each name of escaped variables.\n\n```sh\nshell-general-colors -e _ESC\n# BLACK_ESC, RED_ESC, BOLD_BLACK_ESC ...\n```\n\nYou can use escaped variables with [here documents][]. For example,\n\n```sh\ncat \u003c\u003cEOF\nthis is ${RED_ESC}red${RESET_ALL_ESC}.\nthis is ${YELLOW_ESC}yellow${RESET_ALL_ESC}.\nEOF\n```\n\n### Export both general variables and escaped variables\n\n```sh\nshell-general-colors -a -e _ESC\n# BLACK, BLACK_ESC, RED, RED_ESC, BOLD_BLACK, BOLD_BLACK_ESC ...\n```\n\n## Suggestion, Bug Reporting, Contributing\n\n**Before opening new Issue/Discussion/PR and posting any comments**, please read [Contributing Guidelines](https://gcg.adoyle.me/CONTRIBUTING).\n\n## Copyright and License\n\nCopyright 2019-2023 ADoyle (adoyle.h@gmail.com). Some Rights Reserved.\nThe project is licensed under the **BSD 3-clause License**.\n\nSee the [LICENSE][] file for the specific language governing permissions and limitations under the License.\n\nSee the [NOTICE][] file distributed with this work for additional information regarding copyright ownership.\n\n## References\n\n- [Wikipedia - ANSI escape code](https://www.wikiwand.com/en/ANSI_escape_code)\n- [Stackoverflow - List of ANSI color escape sequences](https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences)\n- [FLOZz' MISC » bash:tip_colors_and_formatting](https://misc.flogisoft.com/bash/tip_colors_and_formatting)\n- [ASCII Table - ANSI Escape sequences](http://ascii-table.com/ansi-escape-sequences.php)\n- [ansi codes](https://bluesock.org/~willkg/dev/ansi.html#sequences)\n- [vt100.net - ANSI Control Functions Summary](https://vt100.net/docs/vt510-rm/chapter4.html)\n- [JAFROG'S DEV BLOG - Colors In Terminal](http://jafrog.com/2013/11/23/colors-in-terminal.html)\n\n## Other Projects\n\n- [lobash](https://github.com/adoyle-h/lobash): A modern, safe, powerful utility/library for Bash script development.\n- [one.bash](https://github.com/one-bash/one.bash): An elegant framework to manage commands, completions, dotfiles for bash players.\n- [Other shell projects](https://github.com/adoyle-h?tab=repositories\u0026q=\u0026type=source\u0026language=shell\u0026sort=stargazers) created by me.\n\n\n\u003c!-- links --\u003e\n\n[issue]: https://github.com/adoyle-h/shell-general-colors/issues\n[tags]: https://github.com/adoyle-h/shell-general-colors/tags\n[LICENSE]: ./LICENSE\n[NOTICE]: ./NOTICE\n[ansi]: https://github.com/fidian/ansi\n[here documents]: http://tldp.org/LDP/abs/html/here-docs.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadoyle-h%2Fshell-general-colors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadoyle-h%2Fshell-general-colors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadoyle-h%2Fshell-general-colors/lists"}