{"id":15203037,"url":"https://github.com/mikesmithgh/git-prompt-string","last_synced_at":"2025-08-01T00:04:36.997Z","repository":{"id":44964127,"uuid":"102654587","full_name":"mikesmithgh/git-prompt-string","owner":"mikesmithgh","description":"📍A shell agnostic git prompt written in Go","archived":false,"fork":false,"pushed_at":"2024-12-12T18:13:54.000Z","size":1184,"stargazers_count":20,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-05T06:54:21.756Z","etag":null,"topics":["bash","bash-prompt","fish","fish-prompt","git","go","golang","oh-my-zsh","powershell","shell-prompt","starship","zsh","zsh-prompt"],"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/mikesmithgh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-06T20:21:36.000Z","updated_at":"2025-01-04T22:29:36.000Z","dependencies_parsed_at":"2024-06-21T07:23:58.532Z","dependency_job_id":"c63cf444-a081-4d5b-95e9-123a4367680b","html_url":"https://github.com/mikesmithgh/git-prompt-string","commit_stats":null,"previous_names":["mikesmithgh/git-prompt-string","mikesmithgh/bgps"],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikesmithgh%2Fgit-prompt-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikesmithgh%2Fgit-prompt-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikesmithgh%2Fgit-prompt-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikesmithgh%2Fgit-prompt-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikesmithgh","download_url":"https://codeload.github.com/mikesmithgh/git-prompt-string/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238743927,"owners_count":19523201,"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","bash-prompt","fish","fish-prompt","git","go","golang","oh-my-zsh","powershell","shell-prompt","starship","zsh","zsh-prompt"],"created_at":"2024-09-28T04:22:52.736Z","updated_at":"2025-02-13T22:31:37.248Z","avatar_url":"https://github.com/mikesmithgh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📍 git-prompt-string\n\ngit-prompt-string is a shell agnostic git prompt written in Go. git-prompt-string provides\ninformation about the current git branch and is inspired by\n[git-prompt.sh](https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh).\n\n[![go](https://img.shields.io/static/v1?style=flat-square\u0026label=\u0026message=v1.22.0\u0026logo=go\u0026labelColor=282828\u0026logoColor=9dbad4\u0026color=9dbad4)](https://go.dev/)\n[![semantic-release: angular](https://img.shields.io/static/v1?style=flat-square\u0026label=semantic-release\u0026message=angular\u0026logo=semantic-release\u0026labelColor=282828\u0026logoColor=d8869b\u0026color=8f3f71)](https://github.com/semantic-release/semantic-release)\n\n![git-prompt-string](https://github.com/mikesmithgh/git-prompt-string/assets/10135646/219854b3-3551-4f4d-8361-175a3eeab3b1)\n\n\u003e [!NOTE]\\\n\u003e Looking for [bgps](https://github.com/mikesmithgh/git-prompt-string/tree/v0.0.1)? git-prompt-string is the successor of bgps.\n\u003e bgps is still available on the tag [v0.0.1](https://github.com/mikesmithgh/git-prompt-string/tree/v0.0.1)\n\u003e\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n- 📦 [Installation](#-installation)\n  - [homebrew tap](#homebrew-tap)\n  - [go install](#go-install)\n  - [manually](#manually)\n- 🛠️ [Setup](#-setup)\n  - [Prompt configuration](#prompt-configuration)\n    - [bash](#bash)\n    - [zsh](#zsh)\n    - [fish](#fish)\n    - [powershell](#powershell)\n    - [nushell](#nushell)\n    - [starship](#starship)\n  - [git-prompt-string configuration](#git-prompt-string-configuration)\n    - [Nerd Font](#nerd-font)\n    - [Configuration file](#configuration-file)\n    - [Configuration options](#configuration-options)\n    - [Specifying colors](#specifying-colors)\n    - [Default configuration](#default-configuration)\n- 📌 [Alternatives](#-alternatives)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n\n## 📦 Installation\n\n### homebrew tap\n\n```sh\nbrew install mikesmithgh/homebrew-git-prompt-string/git-prompt-string\n```\n\n### go install\n\n```sh\ngo install github.com/mikesmithgh/git-prompt-string@latest \n```\n\n### manually\n1. Download pre-compiled binary from [releases](https://github.com/mikesmithgh/git-prompt-string/releases/latest).\n2. If you are on MacOS, run `xattr -c git-prompt-string*.tar.gz` to avoid \"unknown developer\" warning\n3. Extract the `tar.gz` or `zip` file\n4. Move `git-prompt-string` to a file location that is in your `PATH` environment variable\n5. Run `git-prompt-string --version`\n\n#### Example manually downloading via curl on MacOS\n\n```sh\ncurl -L -o git-prompt-string.tar.gz https://github.com/mikesmithgh/git-prompt-string/releases/latest/download/git-prompt-string_Darwin_arm64.tar.gz\nxattr -c git-prompt-string.tar.gz\ntar xzvf git-prompt-string.tar.gz\nmv git-prompt-string \"$HOME/bin\" # replace with your preferred directory that is in PATH\n```\n\n## 🛠️ Setup\n\n### Prompt configuration\n\nSee the following for examples for a reference on how you could add git-prompt-string to your prompt.\n\n#### [bash](https://www.gnu.org/software/bash/)\n\n```sh\nPS1='\\[\\n\\e[0;33m\\w\\e[0m$(git-prompt-string)\\n\\e[0;32mbash \\e[0;36m\\$\\e[0m \\]'\n```\n\n![bash](https://github.com/mikesmithgh/git-prompt-string/assets/10135646/0cd23b15-e12b-4ae6-a51e-20d2b38ea7a0)\n\n#### [zsh](https://www.zsh.org/)\n\n```sh\nautoload -U colors \u0026\u0026 colors\nsetopt PROMPT_SUBST\nPROMPT=$'\\n%{$fg[yellow]%}%~%{$reset_color%}$(git-prompt-string)\\n%{$fg[green]%}zsh %{$fg[cyan]%}%#%{$reset_color%} '\n```\n\n![zsh](https://github.com/mikesmithgh/git-prompt-string/assets/10135646/4ec33fa3-6fc9-4c14-8f4a-7d1daeaeaa3e)\n\n#### [fish](https://fishshell.com/)\n\n```fish\nset -U fish_prompt_pwd_dir_length 0\nfunction fish_prompt\n  set -l symbol ' $ '\n  if fish_is_root_user\n      set symbol ' # '\n  end\n\n  printf '\\n%s%s%s%s\\n%s%sfish%s%s%s' \\\n  (set_color yellow) (prompt_pwd) (set_color normal) (git-prompt-string) \\\n  (set_color green) (set_color blue) (set_color cyan) $symbol (set_color normal)\nend\n```\n\n![fish](https://github.com/mikesmithgh/git-prompt-string/assets/10135646/f4ed0600-e8cd-464f-98bf-5064f00d88d5)\n\n#### [powershell](https://learn.microsoft.com/en-us/powershell/)\n\n```powershell\nfunction prompt {\n    $ESC = [char]27\n    $w = $pwd.Path.Replace($env:USER_PROFILE, \"~\").Replace($env:HOME, \"~\")\n    return \"`n$ESC[0;33m$w$ESC[0m$(git-prompt-string)`n$ESC[0;32mPS $ESC[0;36m\u003e$ESC[0m \"\n}\n```\n\n![pwsh](https://github.com/mikesmithgh/git-prompt-string/assets/10135646/bd712f7a-1ba9-4907-b98a-b8ee35640a50)\n\n#### [nushell](https://www.nushell.sh/)\n\n```nu\n$env.PROMPT_INDICATOR = { ||\n    $\" (ansi cyan)\u003e(ansi reset) \"\n}\n$env.PROMPT_COMMAND = { ||\n    $\"\\n(ansi yellow)($env.PWD | str replace $\"($env.HOME)\" '~')(git-prompt-string)\\n(ansi green)nushell\"\n}\n$env.PROMPT_COMMAND_RIGHT = \"\"\n```\n\n![nu](https://github.com/mikesmithgh/git-prompt-string/assets/10135646/d75dfeed-cd26-4f87-9475-9288df7247e1)\n\n#### [starship](https://starship.rs/config/)\n\nStarship will hide custom commands that fail with a non-zero exit code. To prevent this, add `|| :`\nor your shell's equvilent command to always return a zero exit code. It is recommended to always\nreturn successfully so that error messages are displayed. \n\n```toml\n\"$schema\" = 'https://starship.rs/config-schema.json'\n\nformat = \"\"\"\n$directory\\\n${custom.git-prompt-string}\\\n$line_break\\\n[starship](green) \\\n[\\\\$](cyan) \\\n\"\"\"\n\n[custom.git-prompt-string]\ncommand = \"git-prompt-string || :\"\nwhen = true\n\n[directory]\nhome_symbol='~'\nformat = '[$path]($style)'\ntruncation_length = 0\ntruncate_to_repo = false\nstyle = \"yellow\"\nuse_logical_path = true\n```\n\n![starship](https://github.com/mikesmithgh/git-prompt-string/assets/10135646/6a3d1899-7a81-4dbc-82d4-d6b60fc8513f)\n\n### git-prompt-string configuration\n\n#### Nerd Font\n\nBy default, the powerline icon `` is used as a prefix in the prompt. It is recommended to use a [Nerd Font](https://www.nerdfonts.com/)\nto properly display the `` (nf-pl-branch) icon. See https://www.nerdfonts.com/ to download a Nerd Font. If you\ndo not want this symbol, replace the prompt prefix with \" \". For example, add the following to you git-prompt-string\nconfiguration.\n\n```toml\nprompt_prefix = ' '\n```\n\n#### Configuration file\n\ngit-prompt-string will first check if the `--config` option was passed as an argument. If \n`--config` is set, the filepath defined in the value will be used as the configuration\nfile.\n\nIf `--config` is not set, then git-prompt-string will check if the environment variable \n`$GIT_PROMPT_STRING_CONFIG` is set. If `$GIT_PROMPT_STRING_CONFIG` is set, the \nfilepath defined in the value will be used as the configuration file.\n\nIf `$GIT_PROMPT_STRING_CONFIG` is not set, then git-prompt-string will check if the environment\nvariable `$XDG_CONFIG_HOME` is set. If `$XDG_CONFIG_HOME` is set, the directory defined in then\nvalue will be used as the base directory for git-prompt-string configurations. See \n[XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)\nfor more information on XDG environment variables.\n\nIf `$XDG_CONFIG_HOME` is not set, then `~/.config` and `~/AppData/Local` will be used as the\nbase directory for Unix and Windows, respectively.\n\nThe file defined at `git-prompt-string/config.toml` in the base directory will be used to configure\ngit-prompt-string.\n\n| OS      | Base directory  | Configuration file                            |\n| :------ | :-------------- | :-------------------------------------------- |\n| Unix    | ~/.config       | ~/.config/git-prompt-string/config.toml       |\n| Windows | ~/AppData/Local | ~/AppData/Local/git-prompt-string/config.toml |\n\nIf the configuration filepath is set to the special value of `NONE`, then all user configurations will\nbe ignored. For example, `git-prompt-string --config=NONE` or `GIT_PROMPT_STRING_CONFIG=NONE git-prompt-string`\nwill use the default configuration values defined by git-prompt-string.\n\n#### Configuration options\n\nThe following configuration options are available in either as a command-line argument or TOML key.\n\n```text\n--ahead-format or ahead_format\n      The format used to indicate the number of commits ahead of the\n      remote branch. The %v verb represents the number of commits\n      ahead. One %v verb is required. (default \"↑[%v]\")\n\n--behind-format or behind_format\n      The format used to indicate the number of commits behind the\n      remote branch. The %v verb represents the number of commits\n      behind. One %v verb is required. (default \"↓[%v]\")\n\n--color-clean or color_clean\n      The color of the prompt when the working directory is clean.\n      (default \"green\")\n\n--color-delta or color_delta\n      The color of the prompt when the local branch is ahead, behind,\n      or has diverged from the remote branch. (default \"yellow\")\n\n--color-dirty or color_dirty\n      The color of the prompt when the working directory has changes\n      that have not yet been committed. (default \"red\")\n\n--color-disabled or color_disabled\n      Disable all colors in the color-disabled\n\n--color-merging or color_merging\n      The color of the prompt during a merge, rebase, cherry-pick,\n      revert, or bisect. (default \"blue\")\n\n--color-no-upstream or color_no_upstream\n      The color of the prompt when there is no remote upstream branch.\n      (default \"bright-black\")\n\n--color-untracked or color_untracked\n      The color of the prompt when there are untracked files in the\n      working directory. (default \"magenta\")\n\n--diverged-format or diverged_format\n      The format used to indicate the number of commits diverged\n      from the remote branch. The first %v verb represents the number\n      of commits ahead of the remote branch. The second %v verb\n      represents the number of commits behind the remote branch. Two\n      %v verbs are required. (default \"↕ ↑[%v] ↓[%v]\")\n\n--no-upstream-remote-format or no_upstream_remote_format\n      The format used to indicate when there is no remote upstream,\n      but there is still a remote branch configured. The first %v\n      represents the remote repository. The second %v represents the\n      remote branch. Two %v are required. (default \" → %v/%v\")\n\n--prompt-prefix or prompt_prefix\n      A prefix that is added to the beginning of the prompt. The\n      powerline icon  is used be default. It is recommended to\n      use a Nerd Font to properly display the  (nf-pl-branch) icon.\n      See https://www.nerdfonts.com/ to download a Nerd Font. If you\n      do not want this symbol, replace the prompt prefix with \" \".\n      \\ue0a0 is the unicode representation of . (default \" \\ue0a0 \")\n\n--prompt-suffix or prompt_suffix\n      A suffix that is added to the end of the prompt.\n\n--json\n      Output the results in JSON format. The keys of the JSON result are\n      branchInfo, branchStatus, color, promptPrefix, and promptSuffix.\n    \n      Example:\n      {\n        \"branchInfo\": \"main\",\n        \"branchStatus\": \"\",\n        \"color\": \"green\",\n        \"promptPrefix\": \"  \",\n        \"promptSuffix\": \"\"\n      }\n```\n\n#### Specifying colors\n\nA color value in the configuration must be either a single color or multiple colors\nseparated by white space.\n\nValid formats for a color are:\n- `color`\n- fg:`color`\n- bg:`color`\n- #ffffff\n- #fg:ffffff\n- #bg:ffffff\n- `reset`\n\nThe value `reset` will clear all text formatting and reset the color to the default value.\nColors starting with `bg` or `#bg` are background colors. All other formats are considered\nforeground colors. i.e., `red` is equivalent to `fg:reg`.\n\nColors starting with `#` are considered a hex color code and must have 6 digits.\n\nValid colors are defined in the following table.\n\n| Color          | Code |\n| :------------- | :--  |\n| black          | 0    |\n| red            | 1    |\n| green          | 2    |\n| yellow         | 3    |\n| blue           | 4    |\n| magenta        | 5    |\n| cyan           | 6    |\n| white          | 7    |\n| bright-black   | 8    |\n| bright-red     | 9    |\n| bright-green   | 10   |\n| bright-yellow  | 11   |\n| bright-blue    | 12   |\n| bright-magenta | 13   |\n| bright-cyan    | 14   |\n| bright-white   | 15   |\n\nThe following are examples of valid color configurations:\n\n```toml\ncolor_clean='#e5ee04'\ncolor_no_upstream=\"reset fg:black bg:white\"\ncolor_dirty=\"bg:#b30559\"\ncolor_delta=\"fg:#fcb728\"\ncolor_untracked=\"fg:#ff0000 bg:#16f2aa\"\ncolor_merging=\"bg:#ccccff magenta\"\n```\n\n#### Default configuration\n\n```toml\nprompt_prefix = '  '\nprompt_suffix = ''\nahead_format = '↑[%v]'\nbehind_format = '↓[%v]'\ndiverged_format = '↕ ↑[%v] ↓[%v]'\nno_upstream_remote_format = ' → %v/%v'\ncolor_disabled = false\ncolor_clean = 'green'\ncolor_delta = 'yellow'\ncolor_dirty = 'red'\ncolor_untracked = 'magenta'\ncolor_no_upstream = 'bright-black'\ncolor_merging = 'blue'\n```\n\n## 📌 Alternatives\n- [git-prompt.sh](https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh) - bash/zsh git prompt support\n- [bash-git-prompt](https://github.com/magicmonty/bash-git-prompt) - An informative and fancy bash prompt for Git users\n- [zsh-git-prompt](https://github.com/olivierverdier/zsh-git-prompt) - Informative git prompt for zsh\n- [starship](https://starship.rs/) - The minimal, blazing-fast, and infinitely customizable prompt for any shell!\n  - You can integrate git-prompt-string with starship or use starship's builtin git [configurations](https://starship.rs/config/).\n- [ohmyzsh](https://ohmyz.sh/) - 🙃 A delightful community-driven (with 2,200+ contributors) framework for managing your zsh configuration.\n  - ohmyzsh offers git [plugins](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins) to customize the prompt\n- [powerlevel10k](https://github.com/romkatv/powerlevel10k) - A Zsh theme\n  - powerlevel10k offers [git status](https://github.com/romkatv/powerlevel10k?tab=readme-ov-file#what-do-different-symbols-in-git-status-mean) integration into the prompt\n- [oh-my-posh](https://ohmyposh.dev/) - The most customisable and low-latency cross platform/shell prompt renderer\n  - oh-my-posh offers a [git segment](https://ohmyposh.dev/docs/segments/git) to customize the prompt\n- [fish_git_prompt](https://fishshell.com/docs/current/cmds/fish_git_prompt.html) - Fish has builtin git support to display information about the current git repository, if any.\n- [gitprompt](https://github.com/akupila/gitprompt) - a configurable, fast and zero-dependencies* way of getting the current git status to be displayed in the PROMPT.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikesmithgh%2Fgit-prompt-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikesmithgh%2Fgit-prompt-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikesmithgh%2Fgit-prompt-string/lists"}