Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
732 views
in Technique[技术] by (71.8m points)

break bash: parse_git_branch: command not found

Installed zsh and later on I try to uninstall but it was not installing so I deleted the folders/files manually and after that I started seeing the issues, so everytime I type command in the terminal I see bash: parse_git_branch: command not found

I check it shows that I have default shell is bash (going to system pref->users-)

What do I need to do to bring back the bash? looks like I screwed up the shell, is that possible if I can uninstall and install fresh bash?

I did brew uninstall bash or brew install bash

I get this message:

brew uninstall bash

Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
bash: parse_git_branch: command not found

I try to change ownership to the current logged in user by using this command: after executing the below command I get bash: parse_git_branch: command not found

sudo chown $USER /usr/local/bin/brew

this is how my .bash_profile looks like

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

export PS1="u@h [33[32m]w - $(parse_git_branch)[33[00m] $ "
question from:https://stackoverflow.com/questions/65839161/break-bash-parse-git-branch-command-not-found

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can fix the bash: parse_git_branch: command not found error by editing your ~/.bash_profile file and adding the missing semi-colon:

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

Alternatively, you could put the } on a newline:

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

After you have saved your edits, then you can source your ~/.bash_profile by running

. ~/.bash_profile

After you have sourced your ~/.bash_profile, you can confirm the function was sourced properly by running

type parse_git_branch

This should show the function if it was sourced correctly, or display an error if it was not sourced correctly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...