Change Gnome terminal theme programmatically

bash, linux

Solution

This doesn't do what you asked for, but it probably does what you want.

You can modify your `.bashrc` (or equivalent shell init file) to set your prompt based on whether you're using ssh or not.

i.e. put something like:

if [ -n $SSH_TTY ]; then
     export PS1=`echo -en '\033[42m\w\$ '`;
fi;

at the end of your `.bashrc` file on the remote machine. the `\033[42m` is an ANSI Escape Code that changes the background colour to green.

This way, the background colour of your terminal will be green (or magenta, or cyan, or whatever) only when you're logged in to a remote machine.

Problem

I'd like to create a setup on my local machine (Ubuntu GNOME) whereby the terminal window has a different background color depending on whether I'm logged in to my local machine or ssh'd into a remote machine. Is there a way to do this?

Original source