https://t.co/M4kUzYVPMJ
— LucidBrot (@LucidBrot) September 10, 2020
opening a new terminal with a random color scheme so that I can better distinguish them in the taskbar pic.twitter.com/OWSfoSL2iZ
Please excuse the long whitespace. It's a hack to ensure the page content displays correctly despite this frame not having loaded.
Too often I chose the wrong terminal window from the preview in the taskbar. So I searched for a good solution to randomize the colors, but found none. Which means I made my own.
Create some Terminal Color Profiles in GNOME-Terminal as you would normally, using the GUI. Or grab some from Gogh. You can find a list of the Gogh color schemes I am using at the end of this page.
You could use xdotool
to simulate the keystrokes ShiftF10, r, number as I outlined here, but this introduces bugs if you're too fast at typing. We want a cleaner way, so we modify everything in a cleaner way as I explained there. This second approach works well when you open the terminal with a gnome shortcut, from the taskbar icon, or from the search!
I have explained how to do this and what each step means in my askubuntu answer there. See the following steps for a shortened version.
xxxxxxxxxx
touch /usr/local/bin/gnome-terminal
chmod +x /usr/local/bin/gnome-terminal
Add the following code to /usr/local/bin/gnome-terminal
:
xxxxxxxxxx
set -euo pipefail
# get list of possible profiles, then choose one line at random
line="$(dconf list /org/gnome/terminal/legacy/profiles:/ | grep -e '^:' | shuf -n 1)"
# then remove the leading colon and trailing slash
line="${line#:}"
line="${line%/}"
#/usr/bin/gnome-terminal --profile='7e95bbb3-a584-469d-8ae1-75a08287f55a'
# but also pass all arguments. The profile chosen will always be the last one if there are multiple arguments, so we allow the input to override our setting.
/usr/bin/gnome-terminal --profile="$line" "$@"
If you ever need to open a new terminal without this script running, you'll have to use the full path to /usr/bin/gnome-terminal
.