Written by dustbringer on 27 November 2021 . View source.

Top

Putting git info onto shell prompt

git-prompt.sh

Allows you to see repository status in your command prompt.

The script can be found here.

This can be 'installed' as follows:

  • Copy the file somewhere
  • Then add source path/to/git-prompt.sh at the end of ~/.bashrc

To add git repo information to your bash prompt:

  • Get current prompt layout, $ echo $PS1
  • Copy the output and add $(__git_ps1 " (%s)") somewhere in it
  • Add the line export PS1=YOUR_EDITED_LAYOUT at the end of ~/.bashrc
  • Restart bash
    • If you get the error bash: __git_ps1: command not found, then make sure that the git-prompt.sh is run properly

Source: https://stackoverflow.com/questions/21140815/how-do-i-modify-cygwins-ps1-for-git-bash-completion

Copyright © 2024 dustbringer