Change Gnome Terminal Theme Programmatically

Change Gnome terminal theme programmatically

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.

Mini Project: Change the color of the terminal based on the time of day

If I were doing this, I'd start with PROMPT_COMMAND. Bash will run that script just before displaying a prompt.

You have a couple of choices. You could have a script itself inside PROMPT_COMMAND:

PROMPT_COMMAND='if [ is_morning ]; then echo "MORNING_COLORS'; else echo "EVENING_COLORS"; fi

Or you could have PROMPT_COMMAND run an external command (which could also be a bash script or you could use a different language if you wanted) to do all the work there:

PROMPT_COMMAND=/path/to/setcolor_timeofday

The only hole I see in this is that if you have a program running when the time changes over (for example, using tail -f to watch a file), the background won't change until you return to the bash prompt.

Gnome-terminal --tab variables don't work

$num will interpolate the value of num in the original shell into the string passed as argument to the new /bin/bash.

Use ' instead of " to suppress interpolation.



Related Topics



Leave a reply



Submit