Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I show the current revision/version of the branch in the prompt? #69

Closed
ramonsmits opened this issue Oct 24, 2012 · 5 comments
Closed

Comments

@ramonsmits
Copy link

Posh shows the current branch in the commandprompt but it would be nice if it could also show the current branch revision/version/shorthash.

Maybe this is already possible but I'm not a powershell wizard yet.

@dahlbyk
Copy link
Owner

dahlbyk commented Oct 24, 2012

This is not currently supported. What do you have in mind?

@ramonsmits
Copy link
Author

An easy way to retrieve the hash to be shown on the prompt. I created a function:

function Get-GitRevision()
{
    return git rev-parse HEAD | cut -c0-10>$null
}

This is slow and not really usable for the prompt but it is useful when you want to create a version number in which you want to include the hash.

@JayBazuzi
Copy link
Collaborator

You can do this without relying on cut.exe:

(git rev-parse HEAD).Substring(0,10)

@dahlbyk
Copy link
Owner

dahlbyk commented Oct 26, 2012

Or let git truncate for you: git rev-parse --short HEAD. :)

I'm not comfortable adding the revision to $GitStatus if it requires an extra function call...status makes the prompt slow enough as is. However, my gh69 branch lets you do the following:

$GitPromptSettings.AfterBranchScript = {
    param($status, $backgroundColor, $foregroundColor)
    Write-Prompt " ($(?? (Get-GitRevision -Short) 'new'))" `
        -BackgroundColor $backgroundColor -ForegroundColor $foregroundColor
}

On my machine, that displays the short revision after the branch, in the same color as the branch:

C:\Dev\GitHub\posh-git [gh69 (53ece22)]>

What do you think?

@rkeithhill
Copy link
Collaborator

See issue #345. I think a better approach to such niche customization is to make it easier for folks to customize the content of the Git status summary text rather than adding more & more options to posh-git.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants