{"id":20607279,"url":"https://github.com/akupila/gitprompt","last_synced_at":"2025-09-19T05:48:27.275Z","repository":{"id":57578265,"uuid":"131479421","full_name":"akupila/gitprompt","owner":"akupila","description":"Display git status in the the terminal prompt","archived":false,"fork":false,"pushed_at":"2020-08-12T17:35:58.000Z","size":54,"stargazers_count":25,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T03:55:14.987Z","etag":null,"topics":["bash","git","prompt","ps1","terminal","zsh"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akupila.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}},"created_at":"2018-04-29T08:51:09.000Z","updated_at":"2024-11-29T15:20:54.000Z","dependencies_parsed_at":"2022-08-22T23:50:13.139Z","dependency_job_id":null,"html_url":"https://github.com/akupila/gitprompt","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akupila%2Fgitprompt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akupila%2Fgitprompt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akupila%2Fgitprompt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akupila%2Fgitprompt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akupila","download_url":"https://codeload.github.com/akupila/gitprompt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249003953,"owners_count":21196794,"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","git","prompt","ps1","terminal","zsh"],"created_at":"2024-11-16T10:06:14.385Z","updated_at":"2025-09-19T05:48:22.236Z","avatar_url":"https://github.com/akupila.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gitprompt\n\n[![CircleCI](https://circleci.com/gh/akupila/gitprompt.svg?style=svg)](https://circleci.com/gh/akupila/gitprompt)\n[![goreportcard](https://goreportcard.com/badge/github.com/akupila/gitprompt)](https://goreportcard.com/report/github.com/akupila/gitprompt)\n[![codecov](https://codecov.io/gh/akupila/gitprompt/branch/master/graphs/badge.svg?branch=master)](https://codecov.io/gh/akupila/gitprompt)\n\ngitprompt is a configurable, fast and zero-dependencies* way of getting the\ncurrent git status to be displayed in the `PROMPT`.\n\nOn master without changes:\n\n![gitprompt on master](./screenshot1.png)\n\nOn branch `feature/awesome` with one staged file, one commit ahead origin and\ntwo modified files:\n\n![gitprompt with changes](./screenshot2.png)\n\n_The format is fully customizable, see more below!_\n\nDisplays:\n\n- Current branch / sha1\n- Untracked files\n- Modified files\n- Staged files\n- Commits behind / ahead remote\n\nWhen executed, gitprompt gets the git status of the current working directory\nthen prints it according to the format specified. If the current working\ndirectory is not part of a git repository, gitprompt\nexits with code `0` and no output.\n\n`*` git is required\n\n## Configuration\n\nThe output is configured with `-format` or the `GITPROMPT_FORMAT` environment\nvariable. If both are set, the flag takes precedence.\n\nA very bare-bones format can look like this:\n\n```\ngitprompt -format=\"%h \u003e%s ↓%b ↑%a @%c +%m %u \"\n\n# or\n\nexport GITPROMPT_FORMAT=\"%h \u003e%s ↓%b ↑%a @%c +%m %u \"\ngitprompt\n```\n\nCharacters that don't have a special meaning are printed as usual _(unicode\ncharacters are fine, go crazy with emojis if that's your thing)_.\n\n### Data\n\nVarious data from git can be displayed in the output. Data tokens are prefixed\nwith `%`:\n\n| token | explanation                       |\n| ----- | --------------------------------- |\n| `%h`  | Current branch or sha1            |\n| `%s`  | Number of files staged            |\n| `%b`  | Number of commits behind remote   |\n| `%a`  | Number of commits ahead of remote |\n| `%c`  | Number of conflicts               |\n| `%m`  | Number of files modified          |\n| `%u`  | Number of untracked files         |\n\nNormally `%h` displays the current branch (`master`) but if you're detached\nfrom `HEAD`, it will display the current sha1. Only first 7 characters of the\nsha1 are displayed.\n\n### Colors\n\nThe color can be set with color tokens, prefixed with `#`:\n\n| token | color             |\n| ----- | ----------------- |\n| `#k`  | Black             |\n| `#r`  | Red               |\n| `#g`  | Green             |\n| `#y`  | Yellow            |\n| `#b`  | Blue              |\n| `#m`  | Magenta           |\n| `#c`  | Cyan              |\n| `#w`  | White             |\n| `#K`  | Highlight Black   |\n| `#R`  | Highlight Red     |\n| `#G`  | Highlight Green   |\n| `#Y`  | Highlight Yellow  |\n| `#B`  | Highlight Blue    |\n| `#M`  | Highlight Magenta |\n| `#C`  | Highlight Cyan    |\n| `#W`  | Highlight White   |\n\nThe color is set until another color overrides it, or a group ends (see below).\nIf a color was set when gitprompt is done, it will add a color reset escape\ncode at the end, meaning text after gitprompt won't have the color applied.\n\n### Text attributes\n\nThe text attributes can be set with attribute tokens, prefixed with `@`:\n\n| token | attribute             |\n| ----- | --------------------- |\n| `@b`  | Set bold              |\n| `@B`  | Clear bold            |\n| `@f`  | Set faint/dim color   |\n| `@F`  | Clear faint/dim color |\n| `@i`  | Set italic            |\n| `@I`  | Clear italic          |\n\nAs with colors, if an attribute was set when gitprompt is done, an additional\nescape code is automatically added to clear it.\n\n### Groups\n\nGroups can be used for adding logic to the format. A group's output is only\nprinted if at least one item in the group has data.\n\n| token | action      |\n| ----- | ----------- |\n| `[`   | start group |\n| `]`   | end group   |\n\nConsider the following:\n\n```\n%h[ %a][ %m]\n```\n\nWith `head=master, ahead=3, modified=0`, this will print `master 3` since there\nwere not modified files. Note the space that's included in the group, if\nspacing should be added when the group is present, the spacing should be added\nto the group itself.\n\nColors and attributes are also scoped to a group, meaning they won't leak\noutside so there's no need to reset colors. This prints `behind` in red, `-`\nwithout any formatting, and `ahead` in green:\n\n```\n[#r behind: %b] - [#g ahead: %a]\n```\n\nA group requires one data token to have a non-zero value. The following prints\nthe current branch/sha1 in cyan, then number of staged files (if not zero),\nthen commits behind and ahead (if both are not zero). This allows for symmetry,\nif it's desired to show `master \u003e1 ↓0 ↑2` instead of `master \u003e1 ↑2`:\n\n```\n#c%h[ \u003e%s][ ↓%b ↑%a]\n```\n\n### Complete example\n\nPutting everything together, a complex format may look something like this:\n\n```\ngitprompt -format=\"#B(@b#R%h[#y \u003e%s][#m ↓%b ↑%a][#r x%c][#g +%m][#y ϟ%u]#B) \"\n```\n\n- `(` in highlight blue\n- Current branch/sha1 in bold red\n- If there are staged files, number of staged files in yellow, prefixed with `\u003e`\n- If there are commits ahead or behind, show them with arrows in magenta\n- If there are conflicts, show them in red, prefixed with `x`\n- If files have been modified since the previous commit, show `+3` for 3 modified files\n- If files are untracked (added since last commit), show a lightning and the number in yellow\n- `)` in highlight blue\n\n\u003e Any text printed after gitprompt will have all formatting cleared\n\n## Installation\n\nInstallation consists of two parts: get the binary \u0026 configure your shell to\nuse it.\n\n### Get binary\n\n#### Homebrew\n\nEnsure you have [Homebrew] installed.\n\n```\n$ brew install akupila/gitprompt/gitprompt\n```\n\n#### Install binary directly\n\n##### MacOS\n\n```\n$ curl -sfL https://install.goreleaser.com/github.com/akupila/gitprompt.sh | bash -s -- -b /usr/local/bin\n```\n\nFeel free to change the path from `/usr/local/bin`, just make sure `gitprompt`\nis available on your `$PATH` (check with `gitprompt -version`).\n\n##### Linux\n\n```\n$ curl -sfL https://install.goreleaser.com/github.com/akupila/gitprompt.sh | sudo bash -s -- -b /usr/local/bin\n```\n\n#### Build from source\n\nInstall the go toolchain: https://golang.org/doc/install\n\n```\n$ go get github.com/akupila/gitprompt/...\n```\n\nThe code has no vendored dependencies so no need to worry about that.\n\n### Configure your shell\n\n#### zsh\n\nExecute `gitprompt` as part of `PROMPT`. Add this to your  `~/.zshrc`:\n\n```\nexport PROMPT='$PROMPT %{$(gitprompt -zsh)%}'\n```\n\n\u003e The `-zsh` flag makes `gitprompt` output the correct width of visible\n\u003e characters, which fixes counting ansi color codes (breaks wrapping).\n\nNow reload the config (`source ~/.zshrc`) and gitprompt should show up. Feel\nfree to add anything else here too, just execute `gitprompt` where you want the\nstatus, for example _(this was used for taking the screenshots in the readme)_:\n\n```\nexport PROMPT='%(?:%{$fg_bold[green]%}›:%{$fg_bold[red]%}›) %{$fg[cyan]%}%3d %{$(gitprompt -zsh)%}%{$reset_color%}'\n```\n\n\nAlternatively, you can add this to `RPROMPT` instead, which will make the\nstatus appear on the right hand side of the screen. `gitprompt` will by default\nadd a trailing space so you you may want to customize the formatting if you\ndon't want a trailing space here.\n\n#### bash\n\nSet `PS1` in your `~/.bashrc` and reload the config (`source ~/.bashrc`).\n\nFor example:\n\n```\nexport PS1='$PS1 $(gitprompt)'\n```\n\nSee [bashrcgenerator] for more, just add `$(gitprompt)` where you want the git\nstatus to appear.\n\n### Uninstallation\n\n1. Remove `gitprompt` from your shell config\n2. Delete the binary `rm $(which gitprompt)` or `brew uninstall gitprompt`\n\n\n\n[Homebrew]: https://brew.sh/\n[bashrcgenerator]: http://bashrcgenerator.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakupila%2Fgitprompt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakupila%2Fgitprompt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakupila%2Fgitprompt/lists"}