Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git branch name in prompt

I am able to show the git branch name in the shell prompt. But whenever I am using screen I am getting

bash: parse_git_branch: command not found

and git branch is not shown. Please help me get this in the screen sessions also.

I have following in my .bash_profile.

parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/
}

export PS1="[\W\$(parse_git_branch)]$ "

I don't have .git-completion.bash

System specs:

  • OS: OSX 10.8.4
  • Terminal & iTerm2
  • Screen version: 4.00.03 (FAU) 23-Oct-06
like image 943
user2610733 Avatar asked Jul 23 '13 13:07

user2610733


1 Answers

You are missing a ' at the end of your sed statement:

parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="[\W\$(parse_git_branch)]$ "

Othewerise, it seems to work for me in bash-3.2

like image 86
Nick Tomlin Avatar answered Oct 24 '22 20:10

Nick Tomlin