Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.