{"id":20328737,"url":"https://github.com/allwelldotdev/show-git-branch-bash-sh","last_synced_at":"2025-07-06T18:37:51.241Z","repository":{"id":247947704,"uuid":"827305088","full_name":"allwelldotdev/show-git-branch-bash-sh","owner":"allwelldotdev","description":"Show git branch with color in bash shell prompt","archived":false,"fork":false,"pushed_at":"2024-07-11T12:12:08.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T11:46:30.145Z","etag":null,"topics":["git","linux"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allwelldotdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-07-11T11:47:07.000Z","updated_at":"2024-07-11T12:12:11.000Z","dependencies_parsed_at":"2024-07-11T13:41:54.898Z","dependency_job_id":null,"html_url":"https://github.com/allwelldotdev/show-git-branch-bash-sh","commit_stats":null,"previous_names":["allwelldotdev/show-git-branch-bash-sh"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/allwelldotdev/show-git-branch-bash-sh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allwelldotdev%2Fshow-git-branch-bash-sh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allwelldotdev%2Fshow-git-branch-bash-sh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allwelldotdev%2Fshow-git-branch-bash-sh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allwelldotdev%2Fshow-git-branch-bash-sh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allwelldotdev","download_url":"https://codeload.github.com/allwelldotdev/show-git-branch-bash-sh/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allwelldotdev%2Fshow-git-branch-bash-sh/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262151861,"owners_count":23266929,"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":["git","linux"],"created_at":"2024-11-14T20:07:45.017Z","updated_at":"2025-06-26T22:35:01.173Z","avatar_url":"https://github.com/allwelldotdev.png","language":"Shell","readme":"# Show git branch in your Ubuntu bash shell prompt by editing the PS1\n\n**What is PS1, you may ask?** It's certainly not PlayStation 1, if that's what you thought! 😂 PS1 stands for \"Prompt String 1\". It's an environment variable that defines the primary prompt string in your shell. This is the prompt you see each time you're ready to type a command. It's a crucial part of customizing your shell prompt in Ubuntu (and other Unix-like systems).\n\nA default PS1 looks something like this:\n```\n\\u@\\h:\\w\\$\n```\nWhere:\n- \\u is the current usernae\n- \\h is the hostname\n- \\w is the current working directory\n- $ is a $ for regular users, # for root.\n\n### What to do...\nNow we understand what we're working on, see the file `new_bashrc.sh` for the code.\n\nYou are to paste the code in your user home directory `~/.bashrc` file. But we will not only paste the code, we'll perform a few tweaks as well.\n\n- Glance through your `~/.bashrc` file and within it find the portion of the code file (`new_bashrc.sh`) that reads \"THE 6 LINES BELOW...\"\n- Once you've found it in your user home directory `~/.bashrc` file then comment it out.\n- Paste the uncommented part of the code in `new_bashrc.sh` into your `~/.bashrc` file.\n- source your `~/.bashrc` file to apply the changes in the shell. Use command:\n```bash\nsource ~/.bashrc\n```\n- Now, you should be able to see your git branch name prepended in your shell prompt. Like so.\n![show git branch in bash shell prompt](./show-git-branch-bash-sh-prompt.png)\n\nEnjoy!\n\nPS. You should know this solution causes some performance considerations. In large repositories, checking the git branch for every prompt can slow down your terminal. Some users opt for more optimized solutions or async prompts to mitigate this. Or they simply leave it as it came with Ubuntu (without seeing their git branch in shell prompt, unless they run `git branch` command in the terminal). Pick which works for you, but know the consequences.\n\nPlease raise an issue if you have questions. Thank you!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallwelldotdev%2Fshow-git-branch-bash-sh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallwelldotdev%2Fshow-git-branch-bash-sh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallwelldotdev%2Fshow-git-branch-bash-sh/lists"}