How to best view all available terminal colours
This one-liner will print out all available terminal colours for your chosen Linux terminal application. This is very useful for creating a colourful bash prompt and the user wishes to know which colour codes will work and look good in the terminal.
for x in {0..8}; do for i in {30..37}; do for a in {40..47}; do echo -ne "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m "; done; echo; done; done; echo "" |
This is another way to print the available colours in your chosen terminal.
┌──[jason@11000000.10101000.00000001.00000011]─[~] └──╼ ╼ $ curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash |
This is what the output looks like in Gnome Terminal.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 52 53 54 55 56 57 88 89 90 91 92 93 22 23 24 25 26 27 58 59 60 61 62 63 94 95 96 97 98 99 28 29 30 31 32 33 64 65 66 67 68 69 100 101 102 103 104 105 34 35 36 37 38 39 70 71 72 73 74 75 106 107 108 109 110 111 40 41 42 43 44 45 76 77 78 79 80 81 112 113 114 115 116 117 46 47 48 49 50 51 82 83 84 85 86 87 118 119 120 121 122 123 124 125 126 127 128 129 160 161 162 163 164 165 196 197 198 199 200 201 130 131 132 133 134 135 166 167 168 169 170 171 202 203 204 205 206 207 136 137 138 139 140 141 172 173 174 175 176 177 208 209 210 211 212 213 142 143 144 145 146 147 178 179 180 181 182 183 214 215 216 217 218 219 148 149 150 151 152 153 184 185 186 187 188 189 220 221 222 223 224 225 154 155 156 157 158 159 190 191 192 193 194 195 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
This is a nice example of using colour codes in a bash script.
Each number goes in the colour definition like this;
┌──[jason@11000000.10101000.00000001.00000011]─[~] └──╼ ╼ echo -e "\e[3;37;232m good \e[3;37;0m f" good f
This example above uses the value 232.
The value “\e[3;37;0m” resets the colour values you have set in these examples.
Also, there is the colortest package for Ubuntu and Linux Mint/Debian.
This will print colours to the terminal. Install the package.
sudo apt install colortest |
Then run it to see the available colours.
jason@jason-desktop:~$ colortest-16b |
This will print all of the colour codes for the 16 colour display.
There is also a command that will print all colours for a 256 colour range.
jason@jason-desktop:~$ colortest-256 |
These commands will really help create a bash script with coloured output, and it is desirable to see what the colours look like before using them in your script.