2

My prompt is:

PS1="\`if [ \$? = 0 ]; then echo \[\e[33m\]':)'\[\e[0m\]; else echo \[\e[31m\]':('\[\e[0m\]; fi\` \e[0;1m\w\e[1m\n\$ "

The problem is when I use ls, the prompt changes colors to the color of the last line outputted with ls. For example, if I have a file named z, the prompt changes to grey (to match the color of files from ls) after typing ls, and this behavior is driving me nuts.

Anyone know how I can fix that? I want the entire prompt set to white, with the smilies colored differently.

(My prompt spits out a :) or a :( based on the outcome fo the last command, shows the directory path of pwd, then drops to a new line for command input)

I've enabled force_color_prompt to no avail.

2
  • Are you open to resetting your prompt entirely, or is that not an option?
    – fouric
    Feb 18, 2013 at 5:10
  • That depends I suppose. Is there something in the functionality of my prompt that's causing the issue? I didn't have this problem before on my universities open suse server since ls had no colorize option there, so I assume it's ls colorize that's causing the problem.
    – Dirgon
    Feb 18, 2013 at 15:21

1 Answer 1

1

Solved it.

New prompt (with \u@\h added, since I forgot that) is

export PS1="\e[0;1m\u@\h]\`if [ \$? = 0 ]; then echo \[\e[33m\]':)'\[\e[0m\]; else echo \[\e[31m\]':('\[\e[0m\]; fi\` \e[0;1m\w\e[1m\n\$ "

adding the e[0;1m\ at the very beginning of the prompt began the colorizing of the prompt. Can't believe I overlooked that.

Essentially the prompt changed colors because the terminal changed from the previous color ouputted by ls. I thought that was the problem before but couldn't figure out the syntax needed to colorize the first bit.

You must log in to answer this question.

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