CastorisCausa

Personal blog and hacks by Raymundo Cassani

poshbash in Windows bash

The posh-git-bash prompt, for Git, is a useful tool that shows information about the current status of a local Git repository respect to local and remote (e.g. GitHub) repositories; in this way, it's easy to see if the repository is ahead or behind, has uncommitted changes, is up-to-date, etc.

Alt
Git-Posh example

The posh-git-bash prompt is included in the PowerShell installed with GitHub Desktop software for Windows. This post describes how add the posh-git-bash prompt functionality into the Bash on Windows10.

If Bash on Windows is not already installed, this is the installation guide.


Note: Enable Copy/Paste in Bash
  1. Right click in the Window Title bar > Properties
  2. Enable Quick Edit Mode
  3. Copy is Ctrl-C and Paste is Right-click

Adding posh-git-bash prompt to Bash on Windows

  1. Run Bash and go to HOME directory in bash

    1
    $ cd ~
    
  2. Download the file git-prompt.sh from this repository, and rename it as .git-prompt.sh

    1
    ~$ wget https://raw.githubusercontent.com/lyze/posh-git-sh/master/git-prompt.sh -O .git-prompt.sh
    
  3. Now you need to edit your the file ~/.bashrc Add the following 2 lines at the beginning of ~/.bashrc file, you can use the text editors nano or vim for this.

    1
    2
    source ~/.git-prompt.sh
    PROMPT_COMMAND='__posh_git_ps1 "\u@\h:\w" "\\\$ ";'$PROMPT_COMMAND
    
  4. Restart Bash

Comments

comments powered by Disqus