Skip to content

Display the current Git branch in the Terminal prompt (PS1) #3284

Closed
gitpod-io/workspace-images
#447
@jankeromnes

Description

@jankeromnes

Today, the Git branch/context is not shown in Gitpod's Terminal prompt.

But maybe it could be nice to have it included (this seems to be a common pattern, and Git even comes standard with the dedicated helper __git_ps1).

Current prompt

Screenshot 2021-02-26 at 14 33 39

Proposed new prompt

Screenshot 2021-02-26 at 14 36 05

This can be achieved like so:

PS1='\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\]$(__git_ps1 " (%s)") $ '

Criticism

I believe we've previously decided against having this, because the current branch name is already displayed in the bottom left of the IDE:

Screenshot 2021-02-26 at 14 36 20

However, I personally find it hard to spot, and sometimes still accidentally push to the wrong place because I don't know I'm on the wrong branch.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions