{"id":16359180,"url":"https://github.com/kozova1/bash-segments","last_synced_at":"2026-05-03T22:34:26.444Z","repository":{"id":185164243,"uuid":"263352881","full_name":"Kozova1/Bash-Segments","owner":"Kozova1","description":null,"archived":false,"fork":false,"pushed_at":"2020-05-13T16:53:46.000Z","size":356,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-20T00:07:06.967Z","etag":null,"topics":["bash","bashrc","json","python","python3","toml"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/Kozova1.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}},"created_at":"2020-05-12T13:59:19.000Z","updated_at":"2020-05-16T06:31:00.000Z","dependencies_parsed_at":"2023-08-01T00:16:23.303Z","dependency_job_id":null,"html_url":"https://github.com/Kozova1/Bash-Segments","commit_stats":null,"previous_names":["kozova1/bash-segments"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Kozova1/Bash-Segments","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kozova1%2FBash-Segments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kozova1%2FBash-Segments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kozova1%2FBash-Segments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kozova1%2FBash-Segments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kozova1","download_url":"https://codeload.github.com/Kozova1/Bash-Segments/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kozova1%2FBash-Segments/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32587821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"ssl_error","status_checked_at":"2026-05-03T22:09:10.534Z","response_time":103,"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","bashrc","json","python","python3","toml"],"created_at":"2024-10-11T02:07:43.004Z","updated_at":"2026-05-03T22:34:26.428Z","avatar_url":"https://github.com/Kozova1.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![An image of the example config](./example_config.png)\n# Bash-Segments - Another bash prompt framework\nBash-Segments is a small (less than 200 significant python lines of code) framework for customizing bash prompts. It reads a configuration from a TOML or JSON  file and creates a prompt based on it. \n## Installation\n1. Install `python-toml` by either getting it from your package manager or by running `pip3 install --user toml`\n2. Clone the git repository and make sure you have python 3 installed:\n```bash\ngit clone https://github.com/Kozova1/Bash-Segments ~/.local/share/bash-segments\n```\n3. Create a new config in `$XDG_CONFIG_HOME/bash-segments/prompt.toml` or `$XDG_CONFIG_HOME/bash-segments/prompt.json` or copy the example one to there. If the config is not found in `$XDG_CONFIG_HOME`, it will try to load it from `~/.config/bash-segments/prompt.toml` or `~/.config/bash-segments/prompt.json`.\n4. Add execution permissions to `~/.local/share/bash-segments/segments.py` by running `chmod +x ~/.local/share/bash-segments/segments.py`.\n5. Add the following line to your bashrc and restart your shell (or source the bashrc again):\n```bash\neval $(~/.local/share/bash-segments/segments.py)\n```\n## Configuration\nThe configuration is written using either JSON or TOML, with preference given to TOML.\nThere is some top level config:\n- `separator` - (string, default: `\"|\"`) A character that acts as a separator between segments.\n- `separator_inverse` - (boolean, default: `false`) Whether to swap between the foreground and background color of the separator - required for some powerline symbols to render correctly.\n- `space_at_end` - (boolean, default: `true`) Whether to add a space after the prompt.\n- `segments` - (list of segments, default: `[]`) What segments to put in the prompt.\n- `background_color` - (int, default: `0`) The background color of the terminal, needed for the end of the prompt.\n### Segments\nThe segments consist of 3 or 4 values. In TOML, they are represented using table arrays, for details look [here](https://github.com/toml-lang/toml#user-content-array-of-tables). Here are the available properties:\n- `background` - (int, default: `0`) The background color of the segment (and `separator`).\n- `foreground` - (int, default: `1`) The foreground color of the segment (and `separator`).\n- `type` - (string, default `\"custom\"`) The type of the module to show. If `type` is not `\"custom\"`, `content` will be ignored. The available types are listed [here.](./TYPES.md)\n- `content` - (string, default: `\"?\"`) The contents of the segment. Can include bash escape sequences, as described in [this section in the bash manual.](https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#index-prompting) Do not forget to escape these sequences so that your config doesn't get messed up. ***Will be ignored if*** `type = \"custom\"` ***is not set!***\nThe segments are drawn in the order that they appear in the config file.\n### Colors\nExecute `~/.local/share/bash-segments/colors.py` to print the color palette.\n[Example TOML config](./prompt.toml)\n```toml\nseparator = \"\"\nseparator_inverse = false\nbackground_color = 8\nspace_at_end = false\n\n[[segments]]\ntype = \"username\"\nbackground = 0\nforeground = 7\n\n[[segments]]\ntype = \"hostname-short\"\nbackground = 4\nforeground = 0\n\n[[segments]]\ntype = \"directory\"\nbackground = 2\nforeground = 0\n\n[[segments]]\ntype = \"$\"\nbackground = 1\nforeground = 0\n```\n\n[Example JSON Config](./prompt.json)\n```json\n{\n\t\"separator\": \"\",\n\t\"separator_inverse\": false,\n\t\"background_color\": 8,\n\t\"space_at_end\": false,\n\t\"segments\": [\n\t\t{\n\t\t\t\"type\": \"username\",\n\t\t\t\"background\": 0,\n\t\t\t\"foreground\": 7\n\t\t},\n\t\t{\n\t\t\t\"type\": \"hostname-short\",\n\t\t\t\"background\": 4,\n\t\t\t\"foreground\": 0\n\t\t},\n\t\t{\n\t\t\t\"type\": \"directory\",\n\t\t\t\"background\": 2,\n\t\t\t\"foreground\": 0\n\t\t},\n\t\t{\n\t\t\t\"type\": \"$\",\n\t\t\t\"background\": 1,\n\t\t\t\"foreground\": 0\n\t\t}\n\t]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkozova1%2Fbash-segments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkozova1%2Fbash-segments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkozova1%2Fbash-segments/lists"}