Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 5 down vote accepted

The $ is only needed when reading the current value.

export PS1="test"
share|improve this answer
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. – Wuffers Oct 10 '10 at 13:22

Your export command expanded the prompt variable and tried to export the string "\h:\W \u\". You got an error message because those three substrings don't exist as variable names. As Ignacio Vazquez-Abrams indicated, you need to drop the leading "$" in the export command, which will then export the PROMPT variable as you intended. Brief version: By specifying the PROMPT to be expanded, the command tried to export the wrong thing.

share|improve this answer

You must log in to answer this question.

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