Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Example:

cookie:~ j$ date
Sun Aug  5 02:14:29 CEST 2012
cookie:~ j$

Just as it's pasted here, all three lines are of the same color. I would like to have "cookie:~ j$" or at least part of the string be of a different color than the rest.

I know that I can specifically enable color coding for specific applications like ls or git, but I haven't found anything like this.

Is there a way to change the coloring and format of the static host/path/user string in the Terminal or iTerm?

share|improve this question
1  
This might be useful for you? apple.stackexchange.com/questions/33677/… –  revolver Aug 5 '12 at 1:19
add comment

2 Answers

up vote 0 down vote accepted

What you are looking for us customizing the prompt in the bash shell. Many articles on the web including this one.

This is basically done by setting the variable PS1 e.g.

PS1="\[\033[35m\]\t\[\033[m\]-\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "

gives for user mark on machine flat

enter image description here

This includes \t as time, \u as user \h as hostname and \w current working directory

The \[ then \octal number \] send commands to the terminal , in this case acting as an xterm and sets the colours.

share|improve this answer
add comment

Check out this page for instructions on how to do this http://www.macosxtips.co.uk/index_files/customising-the-terminal.php

share|improve this answer
    
Not an answer. Consider writing an answer rather than just posting a link. –  Max Ried Aug 5 '12 at 9:46
add comment

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.