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.

I would like to use different terminal setting after doing a ssh into another machine. This would mean I could have my terminals to different machine using different colours. Is this possible? Thanks.

share|improve this question
    
Look at customising the prompt in your shell –  Mark Aug 10 '13 at 20:53

2 Answers 2

Yes! It absolutely is possible.

The colors and other aspects of your prompt are controlled by configuration files.

If you're using the default bash, shell then one place where you can configure your prompt is in a file in your home directory called .bash_profile.

Since the .bash_profile file has a "." at the beginning of its name, it may not be visible in Mac Finder windows, but you can see it listed in your terminal among others in your home directory by entering ls -al.

You'll have a .bash_profile file on your own Mac, and you'll also have another one on each remote computer you log into. (Or if the file doesn't exist you're free to create it.)

Put a different prompt config string in each of those files to get different colors on each machine.

What is a prompt config string, and how do you write a custom one?

This guide has full information on all the options you can enter to configure your bash shell prompt, including its colors.

share|improve this answer

Yup. This is possible.

For my laptops I put the following line in .profile:

export PS1="\[\033]0;\w\007\]\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "

On my servers i put the line below in .profile:

export PS1="\[\033]0;\w\007\]\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "

32m and 35m define the colour.

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.