My shell prompt looks like this: ➜ ~ git:(master) ✗. How can I get my normal prompt back?

岁酱吖の 提交于 2020-01-11 06:46:09

问题


My normal terminal command line has suddenly disappeared and has been replaced by this git command line ➜ ~ git:(master) ✗.

How do I get rid of this and go back to my normal command line in Terminal? I on Mac OS X.

I have tried typing exit, Ctrl+c, q, etc. but nothing helped.


回答1:


I know your problem , You are using zsh, right?

If so, you should add export PS1=xxxxx to ~/.zshrc, not ~/.bashrc.

Or you just don't use zsh , input bash and switch to bash.input chsh -s /bin/bash to change the default shell to bash.




回答2:


You must have installed something (I'm not sure what) that modified your prompt to give you context-sensitive information about the Git repository (if any) you're in.

Simply adding

export PS1="\h:\W \u\$ "

at the very bottom of your

  • ~/.bash_profile file, if you use bash, or
  • ~/.zshrc file, if you use zsh,

and then sourcing that file (or restarting Terminal) should rid you of that fancy colourful prompt.




回答3:


This happened to me when getting my head around zsh and git. I created a git repo in the wrong folder and started seeing this zsh context. Because I didn't want a repo in this directory I removed the git information with:

rm -R .git

Note you will only want to do this if you have an invalid git repository.




回答4:


There is nothing wrong with your system or you change something involuntarily. You must have download oh-my-zsh and set your default terminal from bash to zsh. Oh-my-zsh has many different themes, all these themes have different appearances and provide more efficient functions, git information is one of them. The default theme of oh-my-zsh is "robbyrussell" and it just looks like your shell prompt. You can go to "~/.oh-my-zsh/themes" to choose your favorite theme and apply it to the configuration file "./zshrc". I know you have solved the problem by uninstalled the zsh and use the original bash, I just want to tell you the essential reason of this problem. And oh-my-zsh truly provides some convenience which helps you use the command line, maybe you should try it again!




回答5:


I also has this problem like: "➜ ~ git:(master) ✗" on the Mac OS X. Because I type the command "git init".

When I type the command "rm -R .git", it comes back into normal command line in Terminal. PS: I use zsh.




回答6:


I'm assuming you entered "git init" like I did. It took me a while to figure this out, but when you entered "git init" you created a hidden git folder named ".git".

You can see the folder by going to your home directory and typing "ls -a".

Simply remove the file (rm -rf .git), and the prompt will magically disappear.




回答7:


There seems to be a few command line tools that work together with Git that add those customizations.

In my case after installing Drush I got my ~/.bashrc file updated with Drush-specific customizations, which in this case addded a green (master *) $ to the prompt, no matter where I was (very annoying).

Fixed it by commenting out the block after # Include Drush prompt customizations. in my ~/.bashrc and then source ~/.bashrc




回答8:


Open your ZSH config file

sudo vim ~/.zshrc

and paste below command at the bottom of the file

PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} '

this will show current directory




回答9:


if you having seen the (master) in somewhere your folder. try this

git rm .git

It will automatically remove the master



来源:https://stackoverflow.com/questions/25351213/my-shell-prompt-looks-like-this-gitmaster-how-can-i-get-my-normal-pro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!