Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Gnome terminal theme programmatically

Tags:

linux

bash

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?

like image 466
pufferfish Avatar asked Jun 10 '09 09:06

pufferfish


People also ask

How do I customize my GNOME terminal theme?

In GNOME terminal, you reach it through the Application menu along the top of the screen or in the right corner of the window. In Preferences, click the plus symbol (+) next to Profiles to create a new theme profile. In your new profile, click the Colors tab.

How do I change the terminal theme in Centos?

So in terminal click right mouse button -> profiles -> profile preferences -> colors -> background -> choose black.


1 Answers

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.

like image 180
Michiel Buddingh Avatar answered Oct 26 '22 23:10

Michiel Buddingh