{"id":13588224,"url":"https://github.com/ramnes/context-color","last_synced_at":"2025-04-22T15:24:59.684Z","repository":{"id":54689099,"uuid":"117578105","full_name":"ramnes/context-color","owner":"ramnes","description":":rainbow: To each context its own shell color","archived":false,"fork":false,"pushed_at":"2024-05-14T12:25:39.000Z","size":101,"stargazers_count":129,"open_issues_count":5,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-19T20:59:55.684Z","etag":null,"topics":["posix-compliant","shell","terminal","unixporn"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ramnes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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":{"github":["ramnes"],"custom":["https://paypal.me/ramnes"]}},"created_at":"2018-01-15T18:01:58.000Z","updated_at":"2025-02-01T18:55:29.000Z","dependencies_parsed_at":"2024-01-18T04:09:13.003Z","dependency_job_id":"42bebcc1-61b9-4a0d-b999-780674bc8990","html_url":"https://github.com/ramnes/context-color","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramnes%2Fcontext-color","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramnes%2Fcontext-color/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramnes%2Fcontext-color/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramnes%2Fcontext-color/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ramnes","download_url":"https://codeload.github.com/ramnes/context-color/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250265796,"owners_count":21402170,"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":["posix-compliant","shell","terminal","unixporn"],"created_at":"2024-08-01T15:06:34.772Z","updated_at":"2025-04-22T15:24:59.651Z","avatar_url":"https://github.com/ramnes.png","language":"Shell","funding_links":["https://github.com/sponsors/ramnes","https://paypal.me/ramnes"],"categories":["Shell"],"sub_categories":[],"readme":"context-color\n=============\n\n[![Build status](https://github.com/ramnes/context-color/workflows/ci/badge.svg?branch=master)](https://github.com/ramnes/context-color/actions)\n\n:rainbow: To each context its own shell color\n\n![gif](demo.gif)\n\n`context-color` is a simple script that, when executed, outputs a color based\non a command output's hash.\n\n\nExample\n-------\n\nOnce installed somewhere in your `$PATH`, it allows you to do things like this:\n\n```bash\nPS1=\"$(context-color -p)$PS1\\[\\e[0m\\]\"\n```\n\n(where `--prompt/-p` is the switch so that the color is escaped for prompts,\nand `\\[\\e[0m\\]` the escape sequence to reset color)\n\nIf your prompt does not use colors already, this example would customize it so\nthat its color changes according to the current context.\n\nThe default context command (i.e. the command that is used to generate the\nhash) is `whoami; hostname`. If you would just want the color to change\naccording to the hostname, you would change the `CC_CONTEXT` environment\nvariable (`export CC_CONTEXT=\"hostname\"`) or simply use the `--context/-c`\noption (`context-color -c \"hostname\"`).\n\nThen you could make this customization permanent by adding this line to your\n`~/.bashrc`, or to the system-wide `bashrc` file (most likely somewhere in\n`/etc/`, depending on your distribution) if you would want all users to benefit\nfrom this.\n\nIf you are working with several machines, you could either do that manipulation\non every host, or use something like\n[Russell91/xxh](https://github.com/xxh/xxh).\n\n\u003e :warning: Do not use single quotes around your `PS1` value. If you want the\n\u003e color to be evaluated at each prompt, you should use `PROMPT_COMMAND`\n\u003e instead. Here is an example:\n\u003e \n\u003e ```bash\n\u003e PS1=\"$PS1\\[\\e[0m\\]\"\n\u003e PROMPT_COMMAND=\"context-color\"\n\u003e ```\n\nInstall\n-------\n\nSomething in those lines should do it:\n\n```bash\ncd .local/bin/\nwget https://raw.githubusercontent.com/ramnes/context-color/master/context-color\nchmod a+x context-color\n```\n\nThis snippet assumes that `~/.local/bin/` is in your `$PATH` environment\nvariable. If it is not, you can either put `context-color` somewhere else\n(`/usr/local/bin/`, for example), or insert `~/.local/bin/` into your `$PATH`,\nby adding this line into your bash configuration:\n\n```bash\nexport PATH=\"~/.local/bin/:$PATH\"\n```\n\n\nUsage\n-----\n\n```\nusage: context-color [OPTIONS]\n\nPrint a color sequence based on a command output's hash.\n\nCOMMON OPTIONS:\n    --help, -h          Print this help.\n    --background, -b    Use a background sequence rather than foreground.\n    --id, -i            Print the color id rather than the color sequence.\n    --prompt, -p        Declare the sequence as non-printable for prompts.\n\n    --context \u003ccommand\u003e, -c \u003ccommand\u003e\n                        Define the context command on which result the color\n                        will be generated.\n                        The default context is \"whoami; hostname\".\n\n    --exclude \u003ccolors\u003e, -e \u003ccolors\u003e\n                        Comma separated list of color ids not to be used.\n                        Multiple --exclude/-e arguments can be specified.\n                        The default excluded colors are: \"0,7,15\"\n\n    --method \u003cmethod\u003e, -m \u003cmethod\u003e\n                        Choose which hashing method to use. \"sum\" will tend to\n                        give adjacent colors for adjacent context outputs.\n                        \"md5sum\" will give more randomization on colors.\n                        The default method is: \"sum\"\n\nDEBUG OPTIONS:\n    --debug, -d         Output the sequence as a human-readable string and more\n                        useful information.\n    --force \u003ccolor\u003e, -f \u003ccolor\u003e\n                        Ignore the context and force a color id instead.\n```\n\nThe `-p` option must be used if you use `context-color` inside a prompt. It\nmakes your shell understand that the color sequence characters won't be used\nwhen it's trying to guess the space left on the current line. See issue\n[#8](https://github.com/ramnes/context-color/issues/8) for a good description\nof what happens if you do not put `-p` in that situation.\n\n\nCredits\n-------\n\nThe original implementation was based on *J Earls* answer on\n[this SuperUser question](https://superuser.com/questions/1123671).\n\nHe's the real MVP. :ok_hand:\n\n\nLicense\n-------\n\nGNU GPL v3\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framnes%2Fcontext-color","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Framnes%2Fcontext-color","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framnes%2Fcontext-color/lists"}