Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I thought that colored text was just something dictated by my gnome terminal preferences, however, I've discovered there's something slightly more to this because when I'm on my ubuntu VPS, text that should be colored (git commands for example) are just white.

So my first question is, why does my vps have no colors and can I get them "back" relatively easily?

Secondly, just so there is a visual distinction between my local terminal and the VPS, is there a configuration file on the server I can edit, so that all text that normally would be white is now yellow or something?

A few times I've been confused and then realised I'm actually logged into my VPS :P

share|improve this question
    
Which shell are you using on your server? You can check this using ps -p $$. –  Louis Matthijssen May 9 at 10:54

1 Answer 1

There are different files/options controlling this for different programs. For example, to get ls tp print in color, you can use ls --color=tty (which is set by default on Ubuntu). For grep, you can use grep --color=auto. This is handled by the programs themselves, so it's not set in the terminal emulator or the shell. Anyway, to turn on these two options, you can create aliases to them. Edit (or create if not there) ~/.bash_aliases and add these lines:

alias grep='grep --color'
alias ls='ls --color=tty'

Then, open a new terminal (or run . ~/.bash_aliases) and you will have colored ls and grep output.

Anyway, for git, this is set in your ~/.gitrc file (see, for example, here). The easiest trick would be to just copy the one from your machine to the server.


As for differentiating the terminals, the easiest approach would be to color your prompt (PS1). This is set in ~/.bashrc. You can find more details here and an app that simplifies it here but for example, you could use something like this:

PS1='\[\033[01;33m\]\u@\h\[\033[01;34m\] \W \\$\[\033[00m\] '    

Which produces:

enter image description here

and

PS1='\[\033[01;38m\]\u@\h\[\033[01;31m\] \W \\$\[\033[00m\] '    

Which produces:

enter image description here

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.