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
How to Recover or Change Oracle Sysdba Password
Linux Memory Reporting Discrepancy
Check If Vt-D/Iommu Has Been Enabled in The Bios/Uefi
Using <Linux/Types.H> in User Programs, or <Stdint.H> in Driver Module Code...Does It Matter
Icmp Request Received, But Doesn't Reply
Provide Password to Ssh Command Inside Bash Script, Without The Usage of Public Keys and Expect
List of All Folders and Sub-Folders
Print Previous Line If Condition Is Met
Displaying Webcam Video with Qt
Grep Files Based on Time Stamp
Can't Change Tomcat 7 Heap Size
How to Convert Pptx Files to Jpg or Png (For Each Slide) on Linux
Shared Library in Fortran, Minimal Example Does Not Work
How to Find The Processor Queue Length in Linux
Posix Shared Memory and Semaphores Permissions Set Incorrectly by Open Calls
How to Improve Performance of Linux Pipes
Rename Multiple Files While Keeping the Same Extension on Linux