简体   繁体   中英

Overriding bash PS1 not working

I'm trying to update my bash/terminal prompt, but exporting PS1 doesn't do anything.

COMPUTER:~ me$ echo $PS1
\h:\W \u\$
COMPUTER:~ me$ export PS1="foo"
COMPUTER:~ me$ echo $PS1
\h:\W \u\$

I'm on mac OSX Yosemite 10.10.5, Terminal 2.5.3. I've tried placing this in my .bash_profile as well, but nothing seems to override the default PS1. What might be preventing this?

Thanks to 4ae1e1, I checked my PROMPT_COMMAND was set in my .bash_profile for virtual environments.

I changed

PROMPT_COMMAND='__git_ps1 "${VIRTUAL_ENV:+[$Yellow`basename $VIRTUAL_ENV`$Color_Off]\n}" "\h:\W \u\ \\\$ " "[%s]\n"'`

to

PROMPT_COMMAND='__git_ps1 "${VIRTUAL_ENV:+[$Yellow`basename $VIRTUAL_ENV`$Color_Off]\n}" "\w \\\$ " "[%s]\n"'`

(or more clearly the part "\\h:\\W \\u\\ \\\\\\$ " to "\\w \\\\\\$ " )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM