Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Console Foundations Users and Permissions Creating Users

How can I customize my prompt?

On my Mac I have another appear of prompt, and I want it to look the same like in Treehouse console.

2 Answers

Chase Carnaroli
Chase Carnaroli
5,139 Points

Hi Gleb!

If you want to change the prompt in the terminal, type the following:

cd /etc

sudo nano bashrc

enter your password

Then, the file bashrc should pop up.

The text displayed for the prompt is the PS1 variable. Changing that variable will change your prompt. "You can use built-in variables in the string we assign to PS1 to include helpful information in the prompt; here’s a few useful one:

  • \d: Date
  • \h: Host
  • \n: Newline
  • \t: Time
  • \u: Username
  • \W: Current working directory
  • \w: Full path to current directory
  • \n: New line"

(source: https://code.tutsplus.com/tutorials/how-to-customize-the-command-prompt--net-20586)

So, for example, mine is PS1='\u- \W$ ' and displays "(Username)- (current directory)$"

(SUPER IMPORTANT thing to note: there should be no spaces before or after the =. Originally, I accidentally put PS1= '\w\n\u- \W$ ' and it messed up my terminal prompt and it took me a super long to fix my mistake. So DON'T PUT SPACES BEFORE OR AFTER THE EQUAL SIGN!)

Once you are happy with the code you've written for the PS1 variable, go ahead and save it by doing this:

^X

Y

press enter

Now, close your terminal and re-open it. Your prompt should have changed to what you wanted!


If you want to change the look of the terminal (text-color, font size, background color, etc), you can do that by clicking: "Terminal" -> "Preferences..." -> "Profiles"

They actually have a few other designs preloaded. Personally, I use "Homebrew" with the opacity set to 80%.

Hope this helps! - Chase

Hey Gleb,

I'd recommend checking out iTerm and Zsh. I use both in conjunction to create some unique terminal themes. Both are free.