0

Whether or not it was a mess up, this seems to be over my head, and further reading would only get me deeper in trouble. Hence am posting here:

What happened (verbose b/c I am not sure which is relevant):

I was doing "git push" when I was prompted to fix the author name and user email. I copied the command and did it. The command opened an editor (vi), but I didn't know how to close the editor's window. So I closed the Terminal window (w/o editing).

At some point, I was prompted to switch to zsh from bash. I copied the prompt and did it.

Problem is: the prompt became myName@MacBook-Pro % (used to be My-MacBook-Pro $). To remove the % and set the prompt back to default, I read some and followed a tip and did export PS1="\W \$" which resulted in my prompt becoming \W \$. So I did export PS1="$", thinking at least I could get rid of the clutter. But whatever I did, it didn't stick. When I open a new window, the same myName@MacBook-Pro % reappeared.

Set aside what git wants me to do regarding username, how do I get my prompt to get back to default, with username (or MacBook-Pro) and current working directory--most importantly, ending in $ (and not %, which is driving me bananas)?

2

So you're using zsh now not bash?

The following applies to zsh:

To make your change persistent you have to include the export PS1 line in your ~/.zshrc file. If you already have such a file, open it and check for an export PS1 line and edit it to suit your needs.

If not, run:

echo 'export PS1="%M $ "' >> ~/.zshrc

which will change your prompt to include the full machine host name followed by $ as requested (see here for more details).

To see the effects of this change you either need to open a new terminal window or source the .zshrc file (in every terminal that was open when you made the change):

source ~/.zshrc

You can achieve the same results in bash but using either the ~/.bash_profile or ~/.bashrc files (and not forgetting to source them).


A little aside:

I'm sure you've done your research by now but if you get stuck in vim again, the following key combination will help: ESC : q <CR> (where <CR> is the enter key). If you've made changes though this won't work. You can either discard the changes:

ESC : q! <CR>

or write the changes to file:

ESC : wq <CR>

If your experience didn't scare you off from vim, here's a great cheat sheet I'd recommend: https://vim.rtorr.com/

1
  • I have sorta cobbled together a solution, but this response and the tips here helped me understand what happened and how to properly exit the VIM editor. As you suspected, I didn't have the .zshrc file in the system. So creating .zshrc was step one. The first line of suggested code above (starting w echo) - followed by an explanation - is helpful in decoding the cheat sheet. Thanks!
    – YCode
    Mar 28 '20 at 1:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .