summaryrefslogtreecommitdiff
path: root/scripts/24-bit-color.sh
diff options
context:
space:
mode:
authorNathan Lilienthal <nathan@nixpulvis.com>2018-12-08 15:28:57 -0500
committerChristian Duerr <chrisduerr@users.noreply.github.com>2018-12-08 20:28:57 +0000
commitf32facfbfd3d46b76744d118fd2fa5123501f900 (patch)
treea2b8835a62f80faf24d6bd120c6622a317b26b56 /scripts/24-bit-color.sh
parent6b61e967390b2fa4a24f962c4771cdd82e0e9de3 (diff)
downloadalacritty-f32facfbfd3d46b76744d118fd2fa5123501f900.tar.gz
alacritty-f32facfbfd3d46b76744d118fd2fa5123501f900.zip
Refactor Alacritty scripts
This includes some changes to the scripts `README.md` to provide some more information on the different Alacritty scripts. A new script for testing the 24 bit support of Alacritty has been added with the `24-bit-color.sh` name. This should help with troubleshooting truecolor support issues. Since `perf` is a standard tool which is available in the official repositories for most distributions, it doesn't make much sense to provide an installation script specifically for Ubuntu. As a result of this, the script has been removed.
Diffstat (limited to 'scripts/24-bit-color.sh')
-rwxr-xr-xscripts/24-bit-color.sh101
1 files changed, 101 insertions, 0 deletions
diff --git a/scripts/24-bit-color.sh b/scripts/24-bit-color.sh
new file mode 100755
index 00000000..161608fc
--- /dev/null
+++ b/scripts/24-bit-color.sh
@@ -0,0 +1,101 @@
+#!/bin/bash
+# This file was originally taken from iterm2 https://github.com/gnachman/iTerm2/blob/master/tests/24-bit-color.sh
+#
+# This file echoes a bunch of 24-bit color codes
+# to the terminal to demonstrate its functionality.
+# The foreground escape sequence is ^[38;2;<r>;<g>;<b>m
+# The background escape sequence is ^[48;2;<r>;<g>;<b>m
+# <r> <g> <b> range from 0 to 255 inclusive.
+# The escape sequence ^[0m returns output to default
+
+setBackgroundColor()
+{
+ #printf '\x1bPtmux;\x1b\x1b[48;2;%s;%s;%sm' $1 $2 $3
+ printf '\x1b[48;2;%s;%s;%sm' $1 $2 $3
+}
+
+resetOutput()
+{
+ echo -en "\x1b[0m\n"
+}
+
+# Gives a color $1/255 % along HSV
+# Who knows what happens when $1 is outside 0-255
+# Echoes "$red $green $blue" where
+# $red $green and $blue are integers
+# ranging between 0 and 255 inclusive
+rainbowColor()
+{
+ let h=$1/43
+ let f=$1-43*$h
+ let t=$f*255/43
+ let q=255-t
+
+ if [ $h -eq 0 ]
+ then
+ echo "255 $t 0"
+ elif [ $h -eq 1 ]
+ then
+ echo "$q 255 0"
+ elif [ $h -eq 2 ]
+ then
+ echo "0 255 $t"
+ elif [ $h -eq 3 ]
+ then
+ echo "0 $q 255"
+ elif [ $h -eq 4 ]
+ then
+ echo "$t 0 255"
+ elif [ $h -eq 5 ]
+ then
+ echo "255 0 $q"
+ else
+ # execution should never reach here
+ echo "0 0 0"
+ fi
+}
+
+for i in `seq 0 127`; do
+ setBackgroundColor $i 0 0
+ echo -en " "
+done
+resetOutput
+for i in `seq 255 -1 128`; do
+ setBackgroundColor $i 0 0
+ echo -en " "
+done
+resetOutput
+
+for i in `seq 0 127`; do
+ setBackgroundColor 0 $i 0
+ echo -n " "
+done
+resetOutput
+for i in `seq 255 -1 128`; do
+ setBackgroundColor 0 $i 0
+ echo -n " "
+done
+resetOutput
+
+for i in `seq 0 127`; do
+ setBackgroundColor 0 0 $i
+ echo -n " "
+done
+resetOutput
+for i in `seq 255 -1 128`; do
+ setBackgroundColor 0 0 $i
+ echo -n " "
+done
+resetOutput
+
+for i in `seq 0 127`; do
+ setBackgroundColor `rainbowColor $i`
+ echo -n " "
+done
+resetOutput
+for i in `seq 255 -1 128`; do
+ setBackgroundColor `rainbowColor $i`
+ echo -n " "
+done
+resetOutput
+