1

Recently, I changed my terminal prompt name to get rid of everything except the dollar sign. I did this a while ago, and from what I remember, I used System Preferences to make the change rather than my terminal. I want to change my name back to the default settings now, but I'm not sure how to undo this through System Preferences.

Edit: echo $0 gave me an output of -zsh and cat ~/.zprofile | grep -i ps1 output nothing and just printed $ on a new line.

Image of my terminal window

  • 1
    This isn’t a system preference (AFIK) because it can differ depending on the shell you use. You didn’t specify your macOS nor shell, so, start with this: in Terminal, type echo $0. If it says “bash” or “zsh” post the output of cat ~/.bash_profile | grep -i ps1 or cat ~/.zprofile | grep -i ps1 respectively. Be sure to do this with an [edit] to the original question – Allan Jun 13 '23 at 18:45
  • 1
    If nothing was output, see if it is set in .zshrc – Allan Jun 13 '23 at 19:26
  • I don't seem to have a .zshrc -- running ls -a shows .zprofile, .zsh_history, .zsh_sessions, and .zshenv but nothing else related to .zsh – FluffyGhost8 Jun 13 '23 at 19:30
  • That’s ok, many folks use zshrc and zprofile interchangeably. It’s odd that you’re getting a $ prompt since the % is used in Zsh. Can you post the contents of cat ~/.zprofile | pbcopy. It will go to your clipboard so just paste it to the question. Format it if you can (for easy reading; see “help” on right side of AD) – Allan Jun 13 '23 at 19:56
  • Sure, here it is: eval "$(/opt/homebrew/bin/brew shellenv)" – FluffyGhost8 Jun 13 '23 at 20:05
  • Just that one line? – Allan Jun 13 '23 at 20:13
  • Regarding preferences, you could have used Terminal's "Settings". Under "Profiles" and the "Shell" tab, did you set some command to run (for example a command setting prompt) upon startup? – John Palmieri Jun 13 '23 at 20:23
  • @Allan, yes, that is the only line of output I am getting. JohnPalmieri, I can't see a "Profiles" tab, and under the "Shell" tab, there isn't any indication of a command. I'm not sure how to definitively check this, though. – FluffyGhost8 Jun 13 '23 at 20:28
  • What's in .zshenv? – John Palmieri Jun 13 '23 at 20:34
  • . "$HOME/.cargo/env" – FluffyGhost8 Jun 13 '23 at 21:06
  • If you’ve got nothing in there, go ahead and set a prompt in .zprofile. See https://apple.stackexchange.com/a/396296/119271 for an example and reference – Allan Jun 13 '23 at 21:18
  • I added PROMPT='%F{blue}%n%f %#' under that first line of the .zshenv it didn't change anything. I still am only getting a dollar sign as my prompt, and the terminal is still black. – FluffyGhost8 Jun 13 '23 at 21:51
  • When you change and save your .zprofile or .zshenv or .zshrc files, or create them if they don't already exist, you'll need to exit your current shell session and start a new one to get the changes. – Bruce Van Allen Jun 13 '23 at 23:52
  • I don’t recommend putting your prompt in .zshenv. This is for all shells - interactive and non-interactive. There’s no point in setting a prompt in a shell you can’t interact in. Set it in .zprofile instead. See this answer I wrote on the topic. – Allan Jun 14 '23 at 01:13
  • I tried putting PROMPT='%F{blue}%n%f %#' in .zshenv and .zprofile but neither of them changed anything – FluffyGhost8 Jun 14 '23 at 19:28
  • You can resort to basic debugging: first insert echo "hello, this is .zshrc" into your .zshrc (etc.) files. If you don't see "hello ..." when you start a new terminal window, those scripts are not getting executed. If you see them, you can add echo $PROMPT and echo $PS1 into the scripts, say at the top and at the bottom, to see if anything in the scripts is changing them. – John Palmieri Jun 14 '23 at 20:19
  • Was debugging as you mentioned and just found something. It seems that my terminal is automatically running the command export PROMPT=" $";clear; on startup. I only found this by pressing the up arrow immediately after starting the terminal.

    It turns out that for some reason I added a command to run on terminal startup sometime in the past. I found it by clicking on "Terminal > Preferences > Shell". Everything seems to be working as intended now. Thanks for the help!

    – FluffyGhost8 Jun 14 '23 at 20:54

2 Answers2

3

It turns out that for some reason I added a command (EXPORT PROMPT=" $") to run on terminal startup sometime in the past. I found it by clicking on "Terminal > Preferences > Shell". Deleting that command fixed the issue.

1

Here are some examples of what I use at different times, in my .zshrc file:

PS1=" %n @%m %1~ ⚡ "

which gives me (when in my ~/Documents directory):

bw @Redwood Documents ⚡

Or:

PS1=" me here now: %1~ ⚡ "

which shows as:

me here now: Documents ⚡

(I use a colored lightning bolt so it's easy to spot.)

Remember to exit your current shell and start a new one to see the change. If you don't find a .zshrc file in your home directory, create it as a text file.

  • Just tried this -- I created a .zshrc and pasted in your example, but it didn't change anything – FluffyGhost8 Jun 14 '23 at 19:29
  • 1
    Interesting. Mine has survived moving from bash to zsh and several OS upgrades up to the latest. I assume you exited any current terminal session and started a new one, and that you put the file in your home directory. I wonder whether you have some other, perhaps older (bash , maybe?) dot-files still in play. ADDED: Oh, I see you found the problem in your Terminal settings. Good sleuthing! – Bruce Van Allen Jun 15 '23 at 16:00