Skip to content

Instantly share code, notes, and snippets.

@d4rk5eed
Last active July 26, 2022 13:48
Show Gist options
  • Save d4rk5eed/d1651aa46e42d91ef96f to your computer and use it in GitHub Desktop.
Save d4rk5eed/d1651aa46e42d91ef96f to your computer and use it in GitHub Desktop.
How to make prompt with git branch in bash gentoo

How to make prompt with git branch in bash gentoo

  1. emerge app-shells/bash-completion
  2. $ find /usr -name git-prompt.sh.bz2

/usr/share/doc/git-1.8.5.5/git-prompt.sh.bz2 3. cp /usr/share/doc/git-1.8.5.5/git-prompt.sh.bz2 ~ 4. bunzip2 git-prompt.sh.bz2 5. mv git-prompt.sh .git-prompt.sh 6. Paste into ~/.bashrc

    # Bash completion
    if [ -f /etc/bash_completion ]; then
      . /etc/bash_completion
    fi
    
    export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[01;33m\]$(__git_ps1)\[\033[01;34m\] \$\[\033[00m\] '
    export GIT_PS1_SHOWDIRTYSTATE=1

    source ~/.git-prompt.sh

Use GIT_PS1_SHOWDIRTYSTATE for enabling/disabling unmerged code in repository checking.

@robindegen
Copy link

@r7l have you checked the settings that it actually shows the title? That's a setting in xfce-terminal

@r7l
Copy link

r7l commented May 23, 2019

It is set to Dynamically set title and i've tried all the options. It is (and was) working without the above .bashrc lines. It also works perfectly once i ssh into any other machine not having this .bashrc entries

@r7l
Copy link

r7l commented May 23, 2019

It even works when switching to root user as i don't have those entries there. So it has to be within git-prompt.sh file or the 2 export lines

@vitaly-zdanevich
Copy link

Impossible to show numbers, like (master|✖2✚3)?

@robindegen
Copy link

robindegen commented Jul 26, 2022

I don't know; you'd have to check which variables are available within this script

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