{"id":13399039,"url":"https://github.com/dahlbyk/posh-git","last_synced_at":"2025-05-13T20:11:28.089Z","repository":{"id":835462,"uuid":"555374","full_name":"dahlbyk/posh-git","owner":"dahlbyk","description":"A PowerShell environment for Git","archived":false,"fork":false,"pushed_at":"2024-09-02T15:03:06.000Z","size":2966,"stargazers_count":7891,"open_issues_count":108,"forks_count":818,"subscribers_count":183,"default_branch":"master","last_synced_at":"2025-04-08T20:15:41.136Z","etag":null,"topics":["chocolatey","git","powershell","powershell-gallery","powershell-module","powershell-profile","powershell-profile-script","powershell-prompt","profile-script","prompt","psgallery"],"latest_commit_sha":null,"homepage":"http://dahlbyk.github.io/posh-git/","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"joeldiego2895/md-sesion-7","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dahlbyk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","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":["dahlbyk","rkeithhill"]}},"created_at":"2010-03-10T03:52:24.000Z","updated_at":"2025-04-08T10:55:42.000Z","dependencies_parsed_at":"2023-07-09T13:16:29.971Z","dependency_job_id":"8d21bc22-5c81-4fd1-93d3-8b89edd7c8a7","html_url":"https://github.com/dahlbyk/posh-git","commit_stats":{"total_commits":1074,"total_committers":126,"mean_commits":8.523809523809524,"dds":0.5893854748603352,"last_synced_commit":"bbc5ac380018239e0ac70411a59f4e367ca87f2d"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dahlbyk%2Fposh-git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dahlbyk%2Fposh-git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dahlbyk%2Fposh-git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dahlbyk%2Fposh-git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dahlbyk","download_url":"https://codeload.github.com/dahlbyk/posh-git/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251297241,"owners_count":21566779,"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":["chocolatey","git","powershell","powershell-gallery","powershell-module","powershell-profile","powershell-profile-script","powershell-prompt","profile-script","prompt","psgallery"],"created_at":"2024-07-30T19:00:33.650Z","updated_at":"2025-04-28T10:42:04.821Z","avatar_url":"https://github.com/dahlbyk.png","language":"PowerShell","funding_links":["https://github.com/sponsors/dahlbyk","https://github.com/sponsors/rkeithhill"],"categories":["PowerShell","Git Tools","Git工具","🚀 Productivity","Commandline Productivity","Uncategorized","🖥 Windows"],"sub_categories":["REST","Uncategorized","websites to study from"],"readme":"# posh-git\n\n[![Join the chat at https://gitter.im/dahlbyk/posh-git][gitter-img]][gitter]\n[![PowerShell Gallery][psgallery-img]][psgallery-site]\n[![posh-git on Chocolatey][choco-img]][choco-site]\n\nTable of contents:\n\n- [Overview](#overview)\n- [Versions](#versions)\n- [Installation](#installation)\n- [Using posh-git](#using-posh-git)\n- [Git status summary information](#git-status-summary-information)\n- [Customization variables](#customization-variables)\n- [Customizing the posh-git prompt](#customizing-the-posh-git-prompt)\n- [Based on work by](#based-on-work-by)\n\n## Overview\n\nposh-git is a PowerShell module that integrates Git and PowerShell by providing Git status summary information that\ncan be displayed in the PowerShell prompt, e.g.:\n\n![C:\\Users\\Keith\\GitHub\\posh-git [main ≡ +0 ~1 -0 | +0 ~1 -0 !]\u003e ][prompt-def-long]\n\nposh-git also provides tab completion support for common git commands, branch names, paths and more.\nFor example, with posh-git, PowerShell can tab complete git commands like `checkout` by typing `git ch` and pressing\nthe \u003ckbd\u003etab\u003c/kbd\u003e key. That will tab complete to `git checkout` and if you keep pressing \u003ckbd\u003etab\u003c/kbd\u003e, it will\ncycle through other command matches such as `cherry` and `cherry-pick`. You can also tab complete remote names and\nbranch names e.g.: `git pull or\u003ctab\u003e ma\u003ctab\u003e` tab completes to `git pull origin main`.\n\n## Versions\n\n### posh-git v1.0\n\n| Windows (AppVeyor) | Linux/macOS (Travis) | Code Coverage Status |\n|--------------------|----------------------|----------------------|\n| [![master build status][av-master-img]][av-master-site] | [![master build status][tv-master-img]][tv-master-site] | [![master build coverage][cc-master-img]][cc-master-site] |\n\n[README][main-readme] • [CHANGELOG][main-change]\n\n- Supports Windows PowerShell 5.x\n- Supports PowerShell Core 6+ on all platforms\n- Supports [ANSI escape sequences][ansi-esc-code] for color customization\n- Includes breaking changes from v0.x ([roadmap](https://github.com/dahlbyk/posh-git/issues/328))\n  - **All SSH commands removed** from `posh-git` and moved into the new module [posh-sshell][posh-sshell-url]\n\n#### Releases\n\n- v1.1.0\n  ( [README][v1.1-readme] • [CHANGELOG][v1.1-change] )\n- v1.0.0\n  ( [README][v1-readme] • [CHANGELOG][v1-change] )\n- v1.0.0-beta5\n  ( [README][v1b5-readme] • [CHANGELOG][v1b5-change] )\n- v1.0.0-beta4\n  ( [README][v1b4-readme] • [CHANGELOG][v1b4-change] )\n- v1.0.0-beta3\n  ( [README][v1b3-readme] • [CHANGELOG][v1b3-change] )\n- v1.0.0-beta2\n  ( [README][v1b2-readme] • [CHANGELOG][v1b2-change] )\n- v1.0.0-beta1\n  ( [README][v1b1-readme] • [CHANGELOG][v1b1-change] )\n\n### posh-git v0.x\n\n| Windows (AppVeyor) | Code Coverage Status |\n|--------------------|----------------------|\n| [![v0 build status][av-v0-img]][av-v0-site] | [![v0 build coverage][cc-v0-img]][cc-v0-site] |\n\n[README][v0-readme] • [CHANGELOG][v0-change]\n\n- Supports Windows PowerShell 3+\n- Does not support PowerShell Core\n- Avoids breaking changes, maintaining v0.x\n\n#### Releases\n\n- v0.7.3\n  ( [README][v073-readme] • [CHANGELOG][v073-change] )\n- v0.7.1\n  ( [README][v071-readme] • [CHANGELOG][v071-change] )\n- v0.7.0\n  ( [README][v070-readme] • [CHANGELOG][v070-change] )\n\n## Installation\n\nThese installation instructions, as well as the rest of this README, applies only to version 1.x of posh-git.\nFor v0.x installation instructions see this [README][v0-readme].\n\n### Prerequisites\n\nBefore installing posh-git make sure the following prerequisites have been met.\n\n1. Windows PowerShell 5.x or PowerShell Core 6.0.\n   You can get PowerShell Core 6.0 for Windows, Linux or macOS from [here][pscore-install].\n   Check your PowerShell version by executing `$PSVersionTable.PSVersion`.\n\n2. On Windows, script execution policy must be set to either `RemoteSigned` or `Unrestricted`.\n   Check the script execution policy setting by executing `Get-ExecutionPolicy`.\n   If the policy is not set to one of the two required values, run PowerShell as Administrator and\n   execute `Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm`.\n\n3. Git must be installed and available via the PATH environment variable.\n   Check that `git` is accessible from PowerShell by executing `git --version` from PowerShell.\n   If `git` is not recognized as the name of a command, verify that you have Git installed.\n   If not, install Git from [https://git-scm.com](https://git-scm.com).\n   If you have Git installed, make sure the path to git is in your PATH environment variable.\n\n### Installing posh-git via PowerShellGet on Linux, macOS and Windows\n\nposh-git is available on the [PowerShell Gallery][psgallery-v1] and can be installed using the built-in PowerShellGet module.\n\n1. Start Windows PowerShell 5.x or PowerShell \u003e= v6 (`pwsh`).\n\n2. Execute one of the following two commands from an elevated PowerShell prompt,\n   depending on whether (A) you've never installed posh-git, or (B) you've already installed a previous version:\n\n    ```powershell\n    # (A) You've never installed posh-git from the PowerShell Gallery\n    PowerShellGet\\Install-Module posh-git -Scope CurrentUser -Force\n    ```\n\n    \u003e **NOTE**: If you're asked to trust packages from the PowerShell Gallery, answer `yes` to continue installation of posh-git\n\n    OR\n\n    ```powershell\n    # (B) You've already installed a previous version of posh-git from the PowerShell Gallery\n    PowerShellGet\\Update-Module posh-git\n    ```\n\n### Installing posh-git via Chocolatey\n\nIf you prefer to manage posh-git as a Windows package, you can use [Chocolatey](https://chocolatey.org) to install posh-git.\nIf you don't have Chocolatey, you can install it from the [Chocolatey Install page](https://chocolatey.org/install).\nWith Chocolatey installed, execute the following command to install posh-git:\n\n```powershell\nchoco install poshgit\n```\n\n### Installing posh-git via Scoop\n\nAnother popular package manager for Windows is [Scoop](https://scoop.sh/), which you can also use\n to install posh-git. With Scoop installed, execute these commands to install posh-git and import\n it into your profile:\n\n```powershell\nscoop bucket add extras\nscoop install posh-git\nAdd-PoshGitToProfile\n```\n\n### Installing posh-git Manually\n\nIf you need to test/debug changes prior to contributing here, or would otherwise prefer to install posh-git without\nthe aid of a package manager, you can execute `Import-Module \u003cpath-to-src\\posh-git.psd1\u003e`.  For example, if you\nhave git cloned posh-git to `~\\git\\posh-git` you can import this version of posh-git by executing\n`Import-Module ~\\git\\posh-git\\src\\posh-git.psd1`.\n\n## Using posh-git\n\nAfter you have installed posh-git, you need to configure your PowerShell session to use the posh-git module.\n\n### Step 1: Import posh-git\n\nThe first step is to import the module into your PowerShell session which will enable git tab completion.\nYou can do this with the command `Import-Module posh-git`.\n\n### Step 2: Import posh-git from your PowerShell profile\n\nYou do not want to have to manually execute the `Import-Module` command every time you open a new PowerShell prompt.\nLet's have PowerShell import this module for you in each new PowerShell session.\nWe can do this by either executing the command `Add-PoshGitToProfile` or by editing your PowerShell profile script and\nadding the command `Import-Module posh-git`.\n\nIf you want posh-git to be available in all your PowerShell hosts (console, ISE, etc) then execute\n`Add-PoshGitToProfile -AllHosts`. This will add a line containing `Import-Module posh-git` to the file\n`$profile.CurrentUserAllHosts`.\n\nIf you want posh-git to be available in just the current host, then execute `Add-PoshGitToProfile`.\nThis will add the same command but to the file `$profile.CurrentUserCurrentHost`.\n\nIf you want posh-git to be available for all users on the system, start PowerShell as Administrator or\nvia sudo (`sudo pwsh`) on Linux/macOS then execute `Add-PoshGitToProfile -AllUsers -AllHosts`.\nThis will add the import command to `$profile.AllUsersAllHosts`.\n\nIf you want to configure posh-git for all users but only for the current host,\ndrop the `-AllHosts` parameter and the command will modify `$profile.AllUsersCurrentHost`.\n\nIf you'd prefer, you can manually edit the desired PowerShell profile script.\nOpen (or create) your profile script with the command `notepad $profile.CurrentUserAllHosts`.\nIn the profile script, add the following line:\n\n```powershell\nImport-Module posh-git\n```\n\nSave the profile script, then close PowerShell and open a new PowerShell session.\nType `git fe` and then press \u003ckbd\u003etab\u003c/kbd\u003e. If posh-git has been imported, that command should tab complete to\n`git fetch`.\n\nIf you want posh-git to detect your own aliases for git, then you *must* have set the alias *before* importing posh-git.\nSo if you have `Set-Alias g git` then ensure it is executed before `Import-Module posh-git`, and `g checkout` will\ncomplete as if you'd typed `git`.\n\n## Git status summary information\n\nThe Git status summary information provides a wealth of \"Git status\" information at a glance, all the time in your\nprompt.\n\nBy default, the status summary has the following format:\n\n    [{HEAD-name} S +A ~B -C !D | +E ~F -G !H W]\n\n- `[` (`BeforeStatus`)\n- `{HEAD-name}` is the current branch, or the SHA of a detached HEAD\n  - Cyan means the branch matches its remote\n  - Green means the branch is ahead of its remote (green light to push)\n  - Red means the branch is behind its remote\n  - Yellow means the branch is both ahead of and behind its remote\n- `S` represents the branch status in relation to the remote (tracked origin) branch.\n\n  Note: This status information reflects the state of the remote tracked branch after the last `git fetch/pull`\n  of the remote. Execute `git fetch` to update to the latest on the default remote repo. If you have multiple remotes,\n  execute `git fetch --all`.\n\n  - `≡` = The local branch is at the same commit level as the remote branch (`BranchIdenticalStatus`)\n  - `↑\u003cnum\u003e` = The local branch is ahead of the remote branch by the specified number of commits; a `git push` is\n    required to update the remote branch (`BranchAheadStatus`)\n  - `↓\u003cnum\u003e` = The local branch is behind the remote branch by the specified number of commits; a `git pull` is\n    required to update the local branch (`BranchBehindStatus`)\n  - `\u003ca\u003e↕\u003cb\u003e` = The local branch is both ahead of the remote branch by the specified number of commits (a) and behind\n    by the specified number of commits (b); a rebase of the local branch is required before pushing local changes to\n    the remote branch (`BranchBehindAndAheadStatus`).  NOTE: this status is only available if\n    `$GitPromptSettings.BranchBehindAndAheadDisplay` is set to `Compact`.\n  - `×` = The local branch is tracking a branch that is gone from the remote (`BranchGoneStatus`)\n- `ABCD` represent the index; `|` (`DelimStatus`); `EFGH` represent the working directory\n  - `+` = Added files\n  - `~` = Modified files\n  - `-` = Removed files\n  - `!` = Conflicted files\n  - As with `git status` output, index status is displayed in dark green and working directory status in dark red\n\n- `W` represents the overall status of the working directory\n  - `!` = There are unstaged changes in the working tree (`LocalWorkingStatusSymbol`)\n  - `~` = There are uncommitted changes i.e. staged changes in the working tree waiting to be committed (`LocalStagedStatusSymbol`)\n  - None = There are no unstaged or uncommitted changes to the working tree (`LocalDefaultStatusSymbol`)\n- `]` (`AfterStatus`)\n\nThe symbols and surrounding text can be customized by the corresponding properties on `$GitPromptSettings`.\n\nFor example, a status of `[main ≡ +0 ~2 -1 | +1 ~1 -0]` corresponds to the following `git status`:\n\n```powershell\n# On branch main\n#\n# Changes to be committed:\n#   (use \"git reset HEAD \u003cfile\u003e...\" to unstage)\n#\n#        modified:   this-changed.txt\n#        modified:   this-too.txt\n#        deleted:    gone.ps1\n#\n# Changed but not updated:\n#   (use \"git add \u003cfile\u003e...\" to update what will be committed)\n#   (use \"git checkout -- \u003cfile\u003e...\" to discard changes in working directory)\n#\n#        modified:   not-staged.ps1\n#\n# Untracked files:\n#   (use \"git add \u003cfile\u003e...\" to include in what will be committed)\n#\n#        new.file\n```\n\n## Customization variables\n\nposh-git adds variables to your session to let you customize it, including `$GitPromptSettings`, `$GitTabSettings`, and\n`$TortoiseGitSettings`. For an example of how to configure your PowerShell profile script to import the posh-git\nmodule and create a custom prompt function that displays git status info, see the\n[Customizing Your PowerShell Prompt](#customizing-the-posh-git-prompt) section below.\n\nNote on performance: Displaying file status in the git prompt for a very large repo can be prohibitively slow.\nRather than turn off file status entirely (`$GitPromptSettings.EnableFileStatus = $false`), you can disable it on a\nrepo-by-repo basis by adding individual repository paths to `$GitPromptSettings.RepositoriesInWhichToDisableFileStatus`.\n\n## Customizing the posh-git prompt\n\nWhen you import the posh-git module, it will replace PowerShell's default prompt function with a new prompt function.\nThe posh-git prompt function will display Git status summary information when the current directory is inside a Git\nrepository. posh-git will not replace the prompt function if it has detected that you have your own, customized prompt\nfunction.\n\nThe prompt function provided by posh-git creates a prompt that looks like this:\n\n![~\\GitHub\\posh-git [main ≡]\u003e ][prompt-default]\n\nYou can customize the posh-git prompt function or define your own custom prompt function.\nThe rest of this section covers how to customize posh-git's prompt function using the global variable\n`$GitPromptSettings`.\n\n**If you'd like to make any of following changes permanent, i.e. available whenever you start PowerShell, put the\ncorresponding setting(s) in one of your profile scripts after the line that imports posh-git.**\n\nFor instance, you can customize the default prompt prefix to display a colored timestamp with these settings:\n\n```text\n$GitPromptSettings.DefaultPromptPrefix.Text = '$(Get-Date -f \"MM-dd HH:mm:ss\") '\n$GitPromptSettings.DefaultPromptPrefix.ForegroundColor = [ConsoleColor]::Magenta\n```\n\nThis will change the prompt to:\n\n![02-18 13:45:19 ~\\GitHub\\posh-git [main ≡]\u003e ][prompt-prefix]\n\nIf you would prefer not to have any path under your home directory abbreviated with `~`, use the following setting:\n\n```text\n$GitPromptSettings.DefaultPromptAbbreviateHomeDirectory = $false\n```\n\nThis will change the prompt to:\n\n![C:\\Users\\Keith\\GitHub\\posh-git [main ≡]\u003e ][prompt-no-abbr]\n\nIf you would like to change the color of the path, you can use the following setting on Windows:\n\n```text\n$GitPromptSettings.DefaultPromptPath.ForegroundColor = 'Orange'\n```\n\n\u003e Note: Setting the ForegroundColor to a color name, other than one of the standard ConsoleColor names, only works on Windows.\nOn Windows, posh-git uses the `[System.Drawing.ColorTranslator]::FromHtml(string colorName)` method to parse a color\nname as an HTML color. For a complete list of HTML colors, see this [W3Schools page][w3c-colors].\n\nIf you are on Linux or macOS and desire an Orange path, you will need to specify the RGB value for Orange e.g.:\n\n```text\n$GitPromptSettings.DefaultPromptPath.ForegroundColor = 0xFFA500\n```\n\nThis will change the prompt to:\n\n![~\\GitHub\\posh-git [main]\u003e ][prompt-path]\n\nIf you would like to make your prompt span two lines, with a newline after the Git status summary, use this setting:\n\n```text\n$GitPromptSettings.DefaultPromptBeforeSuffix.Text = '`n'\n```\n\nThis will change the prompt to:\n\n![~\\GitHub\\posh-git [main ≡]\u0026#10;\u003e ][prompt-two-line]\n\nYou can swap the order of the path and the Git status summary with the following setting:\n\n```text\n$GitPromptSettings.DefaultPromptWriteStatusFirst = $true\n```\n\nThis will change the prompt to:\n\n![[main ≡] ~\\GitHub\\posh-git\u003e ][prompt-swap]\n\nFinally, you can combine these settings to customize the posh-git prompt fairly significantly.\nIn the `DefaultPromptSuffix` field below, we are prepending the PowerShell history id number before the prompt\nchar `\u003e` e.g.:\n\n```text\n$GitPromptSettings.DefaultPromptWriteStatusFirst = $true\n$GitPromptSettings.DefaultPromptBeforeSuffix.Text = '`n$([DateTime]::now.ToString(\"MM-dd HH:mm:ss\"))'\n$GitPromptSettings.DefaultPromptBeforeSuffix.ForegroundColor = 0x808080\n$GitPromptSettings.DefaultPromptSuffix = ' $((Get-History -Count 1).id + 1)$(\"\u003e\" * ($nestedPromptLevel + 1)) '\n```\n\nThis will change the prompt to:\n\n![[main ≡] ~\\GitHub\\posh-git\u0026#10;02-18 14:04:35 38\u003e ][prompt-custom]\n\nFinally, the path portion of the prompt can be contained within delimiters.\nFor instance, if you would like the containing characters to be red, curly braces, the following settings can be used:\n\n```powershell\n$GitPromptSettings.BeforePath = '{'\n$GitPromptSettings.AfterPath = '}'\n$GitPromptSettings.BeforePath.ForegroundColor = 'Red'\n$GitPromptSettings.AfterPath.ForegroundColor = 'Red'\n```\n\nWith these additional values, the previous prompt would become\n\n![[main ≡] {~\\GitHub\\posh-git}\u0026#10;02-18 14:04:35 38\u003e ][prompt-custom-wpathdelim]\n\n### Prompt Layouts\n\nFor reference, the following layouts show the relative position of the various parts of the posh-git prompt.\nNote that `\u003c\u003e` denotes parts of the prompt that may not appear depending on the status of settings and whether or not\nthe current dir is in a Git repository.\nTo simplify the layout, `DP` is being used as an abbreviation for `DefaultPrompt` settings.\n\nDefault prompt layout:\n\n```text\n{DPPrefix}{BeforePath}{DPPath}{AfterPath}{PathStatusSeparator}\u003c{BeforeStatus}{Status}{AfterStatus}\u003e{DPBeforeSuffix}\u003c{DPDebug}\u003e\u003c{DPTimingFormat}\u003e{DPSuffix}\n```\n\nPrompt layout when DefaultPromptWriteStatusFirst is set to $true:\n\n```text\n{DPPrefix}\u003c{BeforeStatus}{Status}{AfterStatus}\u003e{PathStatusSeparator}{BeforePath}{DPPath}{AfterPath}{DPBeforeSuffix}\u003c{DPDebug}\u003e\u003c{DPTimingFormat}\u003e{DPSuffix}\n```\n\n### Displaying Error Information\n\nIf you want to display the error status of the last command, you can use the values stored in the `$global:GitPromptValues`\nobject which includes the value of `$LastExitCode` and `$?` (represented by the property `DollarQuestion`). Here is\na prompt customization that displays a Red exit code value when `$LastExitCode` is non-zero or a Red `!` if `$?`\nis `$false`:\n\n```powershell\nfunction global:PromptWriteErrorInfo() {\n    if ($global:GitPromptValues.DollarQuestion) { return }\n\n    if ($global:GitPromptValues.LastExitCode) {\n        \"`e[31m(\" + $global:GitPromptValues.LastExitCode + \") `e[0m\"\n    }\n    else {\n        \"`e[31m! `e[0m\"\n    }\n}\n\n$global:GitPromptSettings.DefaultPromptBeforeSuffix.Text = '`n$(PromptWriteErrorInfo)$([DateTime]::now.ToString(\"MM-dd HH:mm:ss\"))'\n```\n\nWhen a PowerShell command fails, this is the prompt you will see:\n\n![~\\GitHub\\posh-git [main ≡]\u0026#10;! 07-01 22:36:31\u003e ][prompt-error1]\n\nWhen an external application returns a non-zero exit code, 1 in this case, you will see the exit code in the prompt:\n\n![~\\GitHub\\posh-git [main ≡]\u0026#10;(1) 07-01 22:32:28\u003e ][prompt-error2]\n\nNote that until you run an external application that sets `$LASTEXITCODE` to zero or you manually set the variable to\n0, you will see the exit code for any error.  In addition to `LastExitCode` and `DollarQuestion`,\n`$global:GitPromptValues` also has `IsAdmin` and `LastPrompt` properties.  The `LastPrompt` property contains the ANSI\nescaped string that was used for the last prompt. This can be useful for debugging your prompt display particularly\nwhen using ANSI/VT sequences.\n\n### $GitPromptScriptBlock\n\nIf you require even more customization than `$GitPromptSettings` provides, you can create your own prompt\nfunction to show whatever information you want.\nSee the [Customizing Your PowerShell Prompt][wiki-custom-prompt] wiki page for details.\n\nHowever, if you need a custom prompt just to perform some non-prompt logic, you can still use posh-git's\nprompt function to write out the prompt string.  This can be done with the `$GitPromptScriptBlock` variable as shown\nbelow e.g.:\n\n```powershell\n# my profile.ps1\nfunction prompt {\n    # Your non-prompt logic here\n\n    # Have posh-git display its default prompt\n    \u0026 $GitPromptScriptBlock\n}\n```\n\nAnd if you'd like to write prompt text before and/or after the posh-git prompt,\nyou can use posh-git's `Write-Prompt` command as shown below:\n\n```powershell\n# my profile.ps1\nfunction prompt {\n    # Your non-prompt logic here\n    $prompt = Write-Prompt \"Text before posh-git prompt \" -ForegroundColor ([ConsoleColor]::Green)\n    $prompt += \u0026 $GitPromptScriptBlock\n    $prompt += Write-Prompt \"Text after posh-git prompt\" -ForegroundColor ([ConsoleColor]::Magenta)\n    if ($prompt) { \"$prompt \" } else { \" \" }\n}\n```\n\n## Based on work by\n\n- Keith Dahlby,   http://solutionizing.net/\n- Mark Embling,   http://www.markembling.info/\n- Jeremy Skinner, http://www.jeremyskinner.co.uk/\n\n[av-master-site]:  https://ci.appveyor.com/project/dahlbyk/posh-git/branch/master\n[av-master-img]:   https://ci.appveyor.com/api/projects/status/eb8erd5afaa01w80/branch/master?svg=true\u0026pendingText=master%20%E2%80%A3%20pending\u0026failingText=master%20%E2%80%A3%20failing\u0026passingText=master%20%E2%80%A3%20passing\n[av-v0-img]:       https://ci.appveyor.com/api/projects/status/eb8erd5afaa01w80/branch/v0?svg=true\u0026pendingText=v0%20%E2%80%A3%20pending\u0026failingText=v0%20%E2%80%A3%20failing\u0026passingText=v0%20%E2%80%A3%20passing\n[av-v0-site]:      https://ci.appveyor.com/project/dahlbyk/posh-git/branch/v0\n\n[tv-master-img]:   https://travis-ci.org/dahlbyk/posh-git.svg?branch=master\n[tv-master-site]:  https://travis-ci.org/dahlbyk/posh-git\n\n[cc-master-img]:   https://coveralls.io/repos/github/dahlbyk/posh-git/badge.svg?branch=master\n[cc-master-site]:  https://coveralls.io/github/dahlbyk/posh-git?branch=master\n[cc-v0-img]:       https://coveralls.io/repos/github/dahlbyk/posh-git/badge.svg?branch=v0\n[cc-v0-site]:      https://coveralls.io/github/dahlbyk/posh-git?branch=v0\n\n[ansi-esc-code]:   https://en.wikipedia.org/wiki/ANSI_escape_code\n[console-vt-seq]:  https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences\n[gitter-img]:      https://badges.gitter.im/dahlbyk/posh-git.svg\n[gitter]:          https://gitter.im/dahlbyk/posh-git?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge\n[pscore-install]:  https://github.com/PowerShell/PowerShell#get-powershell\n\n[choco-img]:       https://img.shields.io/chocolatey/dt/poshgit.svg\n[choco-site]:      https://chocolatey.org/packages/poshgit/\n[psgallery-img]:   https://img.shields.io/powershellgallery/dt/posh-git.svg\n[psgallery-site]:  https://www.powershellgallery.com/packages/posh-git\n[psgallery-v1]:    https://www.powershellgallery.com/packages/posh-git/1.0.0\n[w3c-colors]:      https://www.w3schools.com/colors/colors_names.asp\n\n[posh-sshell-url]: https://github.com/dahlbyk/posh-sshell\n\n[prompt-def-long]: https://github.com/dahlbyk/posh-git/wiki/images/PromptDefaultLong.png   \"~\\GitHub\\posh-git [main ≡ +0 ~1 -0 | +0 ~1 -0 !]\u003e \"\n[prompt-default]:  https://github.com/dahlbyk/posh-git/wiki/images/PromptDefault.png       \"~\\GitHub\\posh-git [main ≡]\u003e \"\n[prompt-prefix]:   https://github.com/dahlbyk/posh-git/wiki/images/PromptPrefix.png        \"02-18 13:45:19 ~\\GitHub\\posh-git [main ≡]\u003e\"\n[prompt-no-abbr]:  https://github.com/dahlbyk/posh-git/wiki/images/PromptNoAbbrevHome.png  \"C:\\Users\\Keith\\GitHub\\posh-git [main ≡]\u003e \"\n[prompt-path]:     https://github.com/dahlbyk/posh-git/wiki/images/PromptOrangePath.png    \"~\\GitHub\\posh-git [main ≡]\u003e \"\n[prompt-swap]:     https://github.com/dahlbyk/posh-git/wiki/images/PromptStatusFirst.png   \"[main ≡] ~\\GitHub\\posh-git\u003e \"\n[prompt-two-line]: https://github.com/dahlbyk/posh-git/wiki/images/PromptTwoLine.png       \"~\\GitHub\\posh-git [main ≡]\u0026#10;\u003e \"\n[prompt-custom]:   https://github.com/dahlbyk/posh-git/wiki/images/PromptCustom.png        \"[main ≡] ~\\GitHub\\posh-git\u0026#10;02-18 14:04:35 38\u003e \"\n[prompt-custom-wpathdelim]:   https://github.com/dahlbyk/posh-git/wiki/images/PromptCustomDelim.png        \"[main ≡] {~\\GitHub\\posh-git}\u0026#10;02-18 14:04:35 38\u003e \"\n[prompt-error1]:   https://github.com/dahlbyk/posh-git/wiki/images/PromptError1.png        \"~\\GitHub\\posh-git [main ≡]\u0026#10;! 07-01 22:36:31\u003e \"\n[prompt-error2]:   https://github.com/dahlbyk/posh-git/wiki/images/PromptError2.png        \"~\\GitHub\\posh-git [main ≡]\u0026#10;(1) 07-01 22:32:28\u003e \"\n\n[v0-change]:       https://github.com/dahlbyk/posh-git/blob/v0/CHANGELOG.md\n[v0-readme]:       https://github.com/dahlbyk/posh-git/blob/v0/README.md\n\n[v070-change]:     https://github.com/dahlbyk/posh-git/blob/v0.7.0/CHANGELOG.md\n[v070-readme]:     https://github.com/dahlbyk/posh-git/blob/v0.7.0/README.md\n\n[v071-change]:     https://github.com/dahlbyk/posh-git/blob/v0.7.1/CHANGELOG.md\n[v071-readme]:     https://github.com/dahlbyk/posh-git/blob/v0.7.1/README.md\n\n[v073-change]:     https://github.com/dahlbyk/posh-git/blob/v0.7.3/CHANGELOG.md\n[v073-readme]:     https://github.com/dahlbyk/posh-git/blob/v0.7.3/README.md\n\n[main-change]:       https://github.com/dahlbyk/posh-git/blob/master/CHANGELOG.md\n[main-readme]:       https://github.com/dahlbyk/posh-git/blob/master/README.md\n\n[v1b1-change]:     https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta1/CHANGELOG.md\n[v1b1-readme]:     https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta1/README.md\n\n[v1b2-change]:     https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta2/CHANGELOG.md\n[v1b2-readme]:     https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta2/README.md\n\n[v1b3-change]:     https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta3/CHANGELOG.md\n[v1b3-readme]:     https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta3/README.md\n\n[v1b4-change]:     https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta4/CHANGELOG.md\n[v1b4-readme]:     https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta4/README.md\n\n[v1b5-change]:     https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta5/CHANGELOG.md\n[v1b5-readme]:     https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta5/README.md\n\n[v1-change]:       https://github.com/dahlbyk/posh-git/blob/v1.0.0/CHANGELOG.md\n[v1-readme]:       https://github.com/dahlbyk/posh-git/blob/v1.0.0/README.md\n\n[v1.1-change]:       https://github.com/dahlbyk/posh-git/blob/v1.1.0/CHANGELOG.md\n[v1.1-readme]:       https://github.com/dahlbyk/posh-git/blob/v1.1.0/README.md\n\n[wiki-custom-prompt]: https://github.com/dahlbyk/posh-git/wiki/Customizing-Your-PowerShell-Prompt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdahlbyk%2Fposh-git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdahlbyk%2Fposh-git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdahlbyk%2Fposh-git/lists"}