You are not logged in.

#1 2015-02-03 14:05:56

MaykeFA
Member
Registered: 2015-01-31
Posts: 13

Show atual git branch in terminal with __git_ps1 problem

I'm having some troubles with __git_ps1 to show the current git branch in terminal. The bug happen if I press TAB, Up, Down or Paste something in terminal.

My PS1 using __git_ps1, not works

export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[31m\] $(__git_ps1 "\033[01;33m{%s}") \033[1;31m$\[\033[00m\] '

My PS1 using a function, not works too

function git_branch_name() {
   git branch 2>/dev/null | grep -e '^*' | sed -E 's/^\* (.+)$/{\1} /'
}
export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[31m\] \033[01;33m$(git_branch_name)\033[1;31m$\[\033[00m\] '

In this example, I used ls /etc and press up key:

WOYbt.jpg

Last edited by MaykeFA (2015-02-03 17:30:27)

Offline

#2 2015-02-03 22:24:41

MaykeFA
Member
Registered: 2015-01-31
Posts: 13

Re: Show atual git branch in terminal with __git_ps1 problem

Solved. Now is working fine with git branch diretory.

export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[31m\] $(__git_ps1 "\[\033[01;33m\]{%s}")\[\033[1;31m\]$\[\033[00m\] '

Offline

Board footer

Powered by FluxBB