General Computing
macos mac bash terminal
Updated Fri, 20 May 2022 01:24:38 GMT

unable to edit bash prompt


I'm on Mac OSX and trying to test out some new prompt settings in terminal. Here's my setup

$ echo $PS1
$ \h:\W \u\$

This prompt works fine. But if I type

$ export $PS1="test"

I get the following errors

-bash: export: `\h:\W': not a valid identifier
-bash: export: `\u\$': not a valid identifier
-bash: export: `=test': not a valid identifier

Any ideas on why this is happening? I don't have a .bashrc file but I do have an /etc/bashrc file




Solution

The $ is only needed when reading the current value.

export PS1="test"




Comments (1)

  • +0 – Yes. You need the $ in a variable to read its value. Example: $PS1. But you do not use a $ when setting its value. Example: PS1. — Oct 10, 2010 at 13:22