{"id":1587,"date":"2014-07-05T01:45:46","date_gmt":"2014-07-05T00:45:46","guid":{"rendered":"http:\/\/blog.spanger.org\/?p=1587"},"modified":"2014-07-21T23:10:32","modified_gmt":"2014-07-21T22:10:32","slug":"randomize-xterm-colors","status":"publish","type":"post","link":"https:\/\/blog.spanger.org\/?p=1587","title":{"rendered":"Randomize xterm colors"},"content":{"rendered":"<p>A bash script to <a href=\"https:\/\/blog.spanger.org\/wp-content\/uploads\/2014\/07\/terminali.jpg\" title=\"randomize\" target=\"_blank\">randomize<\/a> the xterm colors defined in the .Xresources file.<\/p>\n<p><strong>Requirements<\/strong>: An original .Xresources file. It must, among other definitions, specify all the neccesary colors in the following form (order is irrellevant):<\/p>\n<pre>xterm*color0    :  #151503\r\nxterm*color1    :  #843706\r\nxterm*color2    :  #69750e\r\n...\r\nxterm*color15    :  #f4dfd8\r\nxterm*background    :  #211d22<\/pre>\n<p><strong>Usage<\/strong>:<br \/>\nNavigate to the directory where your system&#8217;s .Xresources file is located (most likely your home directory). Make sure it complies with the listed requirements. If so, copy it into a new file to which we from now on refer as the original file. Else edit it so it does and then create the copy:<\/p>\n<pre> cp .Xresources .XresourcesOriginal <\/pre>\n<p>Now we are ready to run the script. Verify that it is located in current directory and classified executable. Then run:<\/p>\n<pre> .\/randXcolors .XresourcesOriginal .Xresources 10 <\/pre>\n<p>Fell free to replace the number 10 with any integer in range from 0 to 255. That is the limit on the randomization range. As it increases the output will in average differ more and more from the original.<br \/>\nAfter the new .Xresources is generated, you can load it:<\/p>\n<pre> xrdb .Xresources <\/pre>\n<p>Restart your xterm to see the change take place. Repeating this process a couple of times will likely provide you with a truly amazing xterm color scheme.<\/p>\n<p><strong>Code<\/strong>:<br \/>\nPaste this into the randXcolor file.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.0em .0em .0em .0em\">\n<pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #8f5902; font-style: italic\">#!\/bin\/bash <\/span>\r\n\r\n<span style=\"color: #8f5902; font-style: italic\"># randXcolors - a bash script to randomize xterm colors<\/span>\r\n\r\n<span style=\"color: #8f5902; font-style: italic\"># Operating on the standard Xresources file it changes the xterm*color* and<\/span>\r\n<span style=\"color: #8f5902; font-style: italic\"># xterm*background variables in order to produce a copy with colors randomized.#<\/span>\r\n<span style=\"color: #8f5902; font-style: italic\"># The new color definitions are placed at the end of the new file.<\/span>\r\n\r\n<span style=\"color: #8f5902; font-style: italic\"># args: 1. filename - Original Xresources file<\/span>\r\n<span style=\"color: #8f5902; font-style: italic\">#       2. filename - Output Xresurces file<\/span>\r\n<span style=\"color: #8f5902; font-style: italic\">#       3. integer - The radius of randomization with regard to the 255 color<\/span>\r\n<span style=\"color: #8f5902; font-style: italic\">#           range<\/span>\r\n\r\nusage<span style=\"color: #ce5c00; font-weight: bold\">(){<\/span>\r\n    <span style=\"color: #204a87\">echo<\/span> -e <span style=\"color: #4e9a06\">&quot;Usage: $0 originalFilename destinationFilename randomRadius\\n&quot;<\/span>\r\n    <span style=\"color: #204a87\">exit <\/span>1\r\n<span style=\"color: #ce5c00; font-weight: bold\">}<\/span>\r\n\r\n<span style=\"color: #204a87; font-weight: bold\">function <\/span>rgb2hex<span style=\"color: #ce5c00; font-weight: bold\">()<\/span>\r\n<span style=\"color: #8f5902; font-style: italic\">#args: RRRGGGBBB color, -001&lt;RRR&lt;256 etc.<\/span>\r\n<span style=\"color: #8f5902; font-style: italic\">#returns #HEXHEX color<\/span>\r\n<span style=\"color: #ce5c00; font-weight: bold\">{<\/span>\r\n    <span style=\"color: #204a87\">local <\/span><span style=\"color: #000000\">hex1<\/span><span style=\"color: #ce5c00; font-weight: bold\">=<\/span><span style=\"color: #204a87; font-weight: bold\">$(<\/span><span style=\"color: #204a87\">printf<\/span> <span style=\"color: #4e9a06\">&#39;%02x&#39;<\/span> <span style=\"color: #204a87; font-weight: bold\">$((<\/span><span style=\"color: #0000cf; font-weight: bold\">10<\/span><span style=\"color: #8f5902; font-style: italic\">#${1:0:3}))) #10# transf 2 dec, $1 is arg<\/span>\r\n    <span style=\"color: #204a87\">local <\/span><span style=\"color: #000000\">hex2<\/span><span style=\"color: #ce5c00; font-weight: bold\">=<\/span><span style=\"color: #204a87; font-weight: bold\">$(<\/span><span style=\"color: #204a87\">printf<\/span> <span style=\"color: #4e9a06\">&#39;%02x&#39;<\/span> <span style=\"color: #204a87; font-weight: bold\">$((<\/span><span style=\"color: #0000cf; font-weight: bold\">10<\/span><span style=\"color: #8f5902; font-style: italic\">#${1:3:3})))<\/span>\r\n    <span style=\"color: #204a87\">local <\/span><span style=\"color: #000000\">hex3<\/span><span style=\"color: #ce5c00; font-weight: bold\">=<\/span><span style=\"color: #204a87; font-weight: bold\">$(<\/span><span style=\"color: #204a87\">printf<\/span> <span style=\"color: #4e9a06\">&#39;%02x&#39;<\/span> <span style=\"color: #204a87; font-weight: bold\">$((<\/span><span style=\"color: #0000cf; font-weight: bold\">10<\/span><span style=\"color: #8f5902; font-style: italic\">#${1:6:3})))<\/span>\r\n    <span style=\"color: #204a87\">echo<\/span> <span style=\"color: #4e9a06\">&quot;#$hex1$hex2$hex3&quot;<\/span>\r\n<span style=\"color: #ce5c00; font-weight: bold\">}<\/span>\r\n\r\n<span style=\"color: #204a87; font-weight: bold\">function <\/span>hex2rgb<span style=\"color: #ce5c00; font-weight: bold\">()<\/span>\r\n<span style=\"color: #8f5902; font-style: italic\">#args: #HEXHEX color<\/span>\r\n<span style=\"color: #8f5902; font-style: italic\">#returns RRRGGGBBB color<\/span>\r\n<span style=\"color: #ce5c00; font-weight: bold\">{<\/span>\r\n    <span style=\"color: #204a87\">local <\/span><span style=\"color: #000000\">rgb1<\/span><span style=\"color: #ce5c00; font-weight: bold\">=<\/span><span style=\"color: #204a87; font-weight: bold\">$(<\/span><span style=\"color: #204a87\">printf<\/span> <span style=\"color: #4e9a06\">&#39;%03d&#39;<\/span> 0x<span style=\"color: #204a87; font-weight: bold\">${<\/span><span style=\"color: #000000\">1<\/span><span style=\"color: #000000; font-weight: bold\">:<\/span><span style=\"color: #000000\">1<\/span><span style=\"color: #000000; font-weight: bold\">:<\/span><span style=\"color: #000000\">2<\/span><span style=\"color: #204a87; font-weight: bold\">})<\/span>\r\n    <span style=\"color: #204a87\">local <\/span><span style=\"color: #000000\">rgb2<\/span><span style=\"color: #ce5c00; font-weight: bold\">=<\/span><span style=\"color: #204a87; font-weight: bold\">$(<\/span><span style=\"color: #204a87\">printf<\/span> <span style=\"color: #4e9a06\">&#39;%03d&#39;<\/span> 0x<span style=\"color: #204a87; font-weight: bold\">${<\/span><span style=\"color: #000000\">1<\/span><span style=\"color: #000000; font-weight: bold\">:<\/span><span style=\"color: #000000\">3<\/span><span style=\"color: #000000; font-weight: bold\">:<\/span><span style=\"color: #000000\">2<\/span><span style=\"color: #204a87; font-weight: bold\">})<\/span>\r\n    <span style=\"color: #204a87\">local <\/span><span style=\"color: #000000\">rgb3<\/span><span style=\"color: #ce5c00; font-weight: bold\">=<\/span><span style=\"color: #204a87; font-weight: bold\">$(<\/span><span style=\"color: #204a87\">printf<\/span> <span style=\"color: #4e9a06\">&#39;%03d&#39;<\/span> 0x<span style=\"color: #204a87; font-weight: bold\">${<\/span><span style=\"color: #000000\">1<\/span><span style=\"color: #000000; font-weight: bold\">:<\/span><span style=\"color: #000000\">5<\/span><span style=\"color: #000000; font-weight: bold\">:<\/span><span style=\"color: #000000\">2<\/span><span style=\"color: #204a87; font-weight: bold\">})<\/span>\r\n    <span style=\"color: #204a87\">echo<\/span> <span style=\"color: #4e9a06\">&quot;$rgb1$rgb2$rgb3&quot;<\/span>\r\n<span style=\"color: #ce5c00; font-weight: bold\">}<\/span>\r\n\r\n<span style=\"color: #204a87; font-weight: bold\">function <\/span>randomizeHex<span style=\"color: #ce5c00; font-weight: bold\">()<\/span>\r\n<span style=\"color: #8f5902; font-style: italic\">#args #HEXHEX color, randomization radius<\/span>\r\n<span style=\"color: #8f5902; font-style: italic\">#returns #HEXHEX randomized color<\/span>\r\n<span style=\"color: #ce5c00; font-weight: bold\">{<\/span>\r\n    <span style=\"color: #204a87\">local <\/span><span style=\"color: #000000\">rgb<\/span><span style=\"color: #ce5c00; font-weight: bold\">=<\/span><span style=\"color: #204a87; font-weight: bold\">$(<\/span>hex2rgb <span style=\"color: #000000\">$1<\/span><span style=\"color: #204a87; font-weight: bold\">)<\/span>\r\n    <span style=\"color: #204a87\">declare<\/span> <span style=\"color: #ce5c00; font-weight: bold\">-<\/span>a <span style=\"color: #204a87\">local <\/span><span style=\"color: #000000\">rgbArr<\/span><span style=\"color: #ce5c00; font-weight: bold\">=(<\/span><span style=\"color: #204a87; font-weight: bold\">${<\/span><span style=\"color: #000000\">rgb<\/span><span style=\"color: #000000; font-weight: bold\">:<\/span><span style=\"color: #000000\">0<\/span><span style=\"color: #000000; font-weight: bold\">:<\/span><span style=\"color: #000000\">3<\/span><span style=\"color: #204a87; font-weight: bold\">}<\/span> <span style=\"color: #204a87; font-weight: bold\">${<\/span><span style=\"color: #000000\">rgb<\/span><span style=\"color: #000000; font-weight: bold\">:<\/span><span style=\"color: #000000\">3<\/span><span style=\"color: #000000; font-weight: bold\">:<\/span><span style=\"color: #000000\">3<\/span><span style=\"color: #204a87; font-weight: bold\">}<\/span> <span style=\"color: #204a87; font-weight: bold\">${<\/span><span style=\"color: #000000\">rgb<\/span><span style=\"color: #000000; font-weight: bold\">:<\/span><span style=\"color: #000000\">6<\/span><span style=\"color: #000000; font-weight: bold\">:<\/span><span style=\"color: #000000\">3<\/span><span style=\"color: #204a87; font-weight: bold\">}<\/span><span style=\"color: #ce5c00; font-weight: bold\">)<\/span>\r\n    <span style=\"color: #204a87\">local <\/span><span style=\"color: #000000\">rgbRand<\/span><span style=\"color: #ce5c00; font-weight: bold\">=<\/span><span style=\"color: #4e9a06\">&quot;&quot;<\/span>\r\n    <span style=\"color: #204a87; font-weight: bold\">for <\/span>i in <span style=\"color: #4e9a06\">&quot;${rgbArr[@]}&quot;<\/span>\r\n    <span style=\"color: #204a87; font-weight: bold\">do<\/span>\r\n<span style=\"color: #204a87; font-weight: bold\">        <\/span><span style=\"color: #204a87\">local <\/span><span style=\"color: #000000\">substr<\/span><span style=\"color: #ce5c00; font-weight: bold\">=<\/span><span style=\"color: #204a87; font-weight: bold\">$(<\/span><span style=\"color: #204a87\">echo<\/span> <span style=\"color: #204a87; font-weight: bold\">$(($(<\/span>shuf -i 0-<span style=\"color: #204a87; font-weight: bold\">$((<\/span><span style=\"color: #000000\">$2<\/span> <span style=\"color: #ce5c00; font-weight: bold\">+<\/span> <span style=\"color: #000000\">$2<\/span><span style=\"color: #204a87; font-weight: bold\">))<\/span> -n 1<span style=\"color: #204a87; font-weight: bold\">)<\/span> <span style=\"color: #ce5c00; font-weight: bold\">-<\/span> <span style=\"color: #000000\">$2<\/span><span style=\"color: #204a87; font-weight: bold\">)))<\/span>\r\n        <span style=\"color: #204a87\">local <\/span><span style=\"color: #000000\">sum<\/span><span style=\"color: #ce5c00; font-weight: bold\">=<\/span><span style=\"color: #204a87; font-weight: bold\">$((<\/span><span style=\"color: #0000cf; font-weight: bold\">10<\/span><span style=\"color: #8f5902; font-style: italic\">#$i + $substr))<\/span>\r\n        <span style=\"color: #204a87; font-weight: bold\">if<\/span> <span style=\"color: #ce5c00; font-weight: bold\">[<\/span> <span style=\"color: #000000\">$sum<\/span> <span style=\"color: #ce5c00; font-weight: bold\">-<\/span>gt <span style=\"color: #4e9a06\">&quot;255&quot;<\/span> <span style=\"color: #ce5c00; font-weight: bold\">]<\/span>; <span style=\"color: #204a87; font-weight: bold\">then<\/span>\r\n<span style=\"color: #204a87; font-weight: bold\">            <\/span><span style=\"color: #000000\">sum<\/span><span style=\"color: #ce5c00; font-weight: bold\">=<\/span><span style=\"color: #4e9a06\">&quot;255&quot;<\/span>\r\n        <span style=\"color: #204a87; font-weight: bold\">elif<\/span> <span style=\"color: #ce5c00; font-weight: bold\">[<\/span> <span style=\"color: #000000\">$sum<\/span> <span style=\"color: #ce5c00; font-weight: bold\">-<\/span>lt <span style=\"color: #4e9a06\">&quot;0&quot;<\/span> <span style=\"color: #ce5c00; font-weight: bold\">]<\/span>; <span style=\"color: #204a87; font-weight: bold\">then<\/span>\r\n<span style=\"color: #204a87; font-weight: bold\">            <\/span><span style=\"color: #000000\">sum<\/span><span style=\"color: #ce5c00; font-weight: bold\">=<\/span><span style=\"color: #4e9a06\">&quot;0&quot;<\/span>\r\n        <span style=\"color: #204a87; font-weight: bold\">fi<\/span>\r\n<span style=\"color: #204a87; font-weight: bold\">        <\/span><span style=\"color: #000000\">rgbRand<\/span><span style=\"color: #ce5c00; font-weight: bold\">=<\/span><span style=\"color: #4e9a06\">&quot;$rgbRand$(printf &#39;%03d&#39; $sum)&quot;<\/span>\r\n    <span style=\"color: #204a87; font-weight: bold\">done<\/span>\r\n<span style=\"color: #204a87; font-weight: bold\">    <\/span><span style=\"color: #204a87\">echo<\/span> <span style=\"color: #204a87; font-weight: bold\">$(<\/span>rgb2hex <span style=\"color: #000000\">$rgbRand<\/span><span style=\"color: #204a87; font-weight: bold\">)<\/span>\r\n<span style=\"color: #ce5c00; font-weight: bold\">}<\/span>\r\n\r\n<span style=\"color: #8f5902; font-style: italic\">#input check<\/span>\r\n<span style=\"color: #ce5c00; font-weight: bold\">[[<\/span> <span style=\"color: #000000\">$# <\/span><span style=\"color: #ce5c00; font-weight: bold\">-<\/span>ne <span style=\"color: #0000cf; font-weight: bold\">3<\/span> <span style=\"color: #ce5c00; font-weight: bold\">]]<\/span> <span style=\"color: #ce5c00; font-weight: bold\">&amp;&amp;<\/span> <span style=\"color: #204a87\">echo<\/span> <span style=\"color: #ce5c00; font-weight: bold\">-<\/span>e <span style=\"color: #4e9a06\">&quot;\\nERROR\\nWrong number of arguments.\\n&quot;<\/span> <span style=\"color: #ce5c00; font-weight: bold\">&amp;&amp;<\/span> usage\r\n<span style=\"color: #ce5c00; font-weight: bold\">[[<\/span> <span style=\"color: #000000\">$1<\/span> <span style=\"color: #ce5c00; font-weight: bold\">==<\/span> <span style=\"color: #000000\">$2<\/span> <span style=\"color: #ce5c00; font-weight: bold\">]]<\/span> <span style=\"color: #ce5c00; font-weight: bold\">&amp;&amp;<\/span> <span style=\"color: #204a87\">echo<\/span> <span style=\"color: #ce5c00; font-weight: bold\">-<\/span>e <span style=\"color: #4e9a06\">&quot;\\nERROR\\nDo not use the same file as input and&quot;\\<\/span>\r\n    <span style=\"color: #4e9a06\">&quot;output.\\nExiting...\\n&quot;\\ <\/span><span style=\"color: #ce5c00; font-weight: bold\">&amp;&amp;<\/span> <span style=\"color: #204a87\">exit <\/span><span style=\"color: #0000cf; font-weight: bold\">1<\/span>\r\n<span style=\"color: #ce5c00; font-weight: bold\">[[<\/span> <span style=\"color: #000000\">$3<\/span> <span style=\"color: #ce5c00; font-weight: bold\">-<\/span>gt <span style=\"color: #0000cf; font-weight: bold\">255<\/span> <span style=\"color: #ce5c00; font-weight: bold\">]]<\/span> <span style=\"color: #ce5c00; font-weight: bold\">||<\/span> <span style=\"color: #ce5c00; font-weight: bold\">[[<\/span> <span style=\"color: #000000\">$3<\/span> <span style=\"color: #ce5c00; font-weight: bold\">-<\/span>lt <span style=\"color: #0000cf; font-weight: bold\">0<\/span> <span style=\"color: #ce5c00; font-weight: bold\">]]<\/span> <span style=\"color: #ce5c00; font-weight: bold\">&amp;&amp;<\/span> <span style=\"color: #204a87\">echo<\/span> <span style=\"color: #ce5c00; font-weight: bold\">-<\/span>e <span style=\"color: #4e9a06\">&quot;\\nERROR.\\nThe randomization&quot;\\<\/span>\r\n    <span style=\"color: #4e9a06\">&quot;radius too large or too small to make any sense.\\nUse values between 0&quot;\\<\/span>\r\n    <span style=\"color: #4e9a06\">&quot;and 255, with less then 100 recommended.\\nExiting...\\n&quot;<\/span> <span style=\"color: #ce5c00; font-weight: bold\">&amp;&amp;<\/span> <span style=\"color: #204a87\">exit <\/span><span style=\"color: #0000cf; font-weight: bold\">1<\/span>\r\n\r\n<span style=\"color: #8f5902; font-style: italic\">#&quot;main&quot; function<\/span>\r\ncp <span style=\"color: #4e9a06\">&quot;$PWD\/$1&quot;<\/span> <span style=\"color: #4e9a06\">&quot;$PWD\/$2&quot;<\/span>\r\nsed <span style=\"color: #ce5c00; font-weight: bold\">-<\/span>i <span style=\"color: #4e9a06\">&#39;\/[Xx][Tt]erm\\*color*\/d&#39;<\/span> <span style=\"color: #4e9a06\">&quot;$PWD\/$2&quot;<\/span>\r\nsed <span style=\"color: #ce5c00; font-weight: bold\">-<\/span>i <span style=\"color: #4e9a06\">&#39;\/[Xx][Tt]erm\\*background*\/d&#39;<\/span> <span style=\"color: #4e9a06\">&quot;$PWD\/$2&quot;<\/span>\r\n<span style=\"color: #000000\">count<\/span><span style=\"color: #ce5c00; font-weight: bold\">=<\/span><span style=\"color: #0000cf; font-weight: bold\">0<\/span>\r\n<span style=\"color: #204a87; font-weight: bold\">while <\/span><span style=\"color: #204a87\">read <\/span>l; <span style=\"color: #204a87; font-weight: bold\">do<\/span>\r\n<span style=\"color: #204a87; font-weight: bold\">    if<\/span> <span style=\"color: #ce5c00; font-weight: bold\">[<\/span> <span style=\"color: #204a87; font-weight: bold\">${<\/span><span style=\"color: #000000\">l<\/span><span style=\"color: #000000; font-weight: bold\">:<\/span><span style=\"color: #000000\">0<\/span><span style=\"color: #000000; font-weight: bold\">:<\/span><span style=\"color: #000000\">1<\/span><span style=\"color: #204a87; font-weight: bold\">}<\/span> !<span style=\"color: #ce5c00; font-weight: bold\">=<\/span> <span style=\"color: #4e9a06\">&quot;!&quot;<\/span> <span style=\"color: #ce5c00; font-weight: bold\">]<\/span>; <span style=\"color: #204a87; font-weight: bold\">then<\/span> <span style=\"color: #8f5902; font-style: italic\">#dont touch comments<\/span>\r\n        <span style=\"color: #204a87; font-weight: bold\">if<\/span> <span style=\"color: #ce5c00; font-weight: bold\">[[<\/span> <span style=\"color: #000000\">$l<\/span> <span style=\"color: #ce5c00; font-weight: bold\">==<\/span> <span style=\"color: #ce5c00; font-weight: bold\">*[<\/span>Xx<span style=\"color: #ce5c00; font-weight: bold\">][<\/span>Tt<span style=\"color: #ce5c00; font-weight: bold\">]<\/span>erm<span style=\"color: #4e9a06\">\\*<\/span>color* <span style=\"color: #ce5c00; font-weight: bold\">]]<\/span>; <span style=\"color: #204a87; font-weight: bold\">then<\/span>\r\n<span style=\"color: #204a87; font-weight: bold\">            <\/span><span style=\"color: #204a87\">echo<\/span> <span style=\"color: #4e9a06\">&quot;xterm*color&quot;<\/span><span style=\"color: #000000\">$count<\/span><span style=\"color: #4e9a06\">&quot;    :  &quot;<\/span><span style=\"color: #204a87; font-weight: bold\">$(<\/span>randomizeHex <span style=\"color: #4e9a06\">&quot;#${l#*#}&quot;<\/span> <span style=\"color: #000000\">$3<\/span><span style=\"color: #204a87; font-weight: bold\">)<\/span> <span style=\"color: #4e9a06\">\\<\/span>\r\n                &gt;&gt; <span style=\"color: #4e9a06\">&quot;$PWD\/$2&quot;<\/span>\r\n            <span style=\"color: #000000\">count<\/span><span style=\"color: #ce5c00; font-weight: bold\">=<\/span><span style=\"color: #204a87; font-weight: bold\">$((<\/span><span style=\"color: #000000\">$count<\/span> <span style=\"color: #ce5c00; font-weight: bold\">+<\/span> <span style=\"color: #0000cf; font-weight: bold\">1<\/span><span style=\"color: #204a87; font-weight: bold\">))<\/span>\r\n        <span style=\"color: #204a87; font-weight: bold\">elif<\/span> <span style=\"color: #ce5c00; font-weight: bold\">[[<\/span> <span style=\"color: #000000\">$l<\/span> <span style=\"color: #ce5c00; font-weight: bold\">==<\/span> <span style=\"color: #ce5c00; font-weight: bold\">*[<\/span>Xx<span style=\"color: #ce5c00; font-weight: bold\">][<\/span>Tt<span style=\"color: #ce5c00; font-weight: bold\">]<\/span>erm<span style=\"color: #4e9a06\">\\*<\/span>background* <span style=\"color: #ce5c00; font-weight: bold\">]]<\/span>; <span style=\"color: #204a87; font-weight: bold\">then<\/span>\r\n<span style=\"color: #204a87; font-weight: bold\">            <\/span><span style=\"color: #204a87\">echo<\/span> <span style=\"color: #4e9a06\">&quot;xterm*background    :  &quot;<\/span><span style=\"color: #204a87; font-weight: bold\">$(<\/span>randomizeHex <span style=\"color: #4e9a06\">&quot;#${l#*#}&quot;<\/span> <span style=\"color: #000000\">$3<\/span><span style=\"color: #204a87; font-weight: bold\">)<\/span> <span style=\"color: #4e9a06\">\\<\/span>\r\n                &gt;&gt; <span style=\"color: #4e9a06\">&quot;$PWD\/$2&quot;<\/span>\r\n        <span style=\"color: #204a87; font-weight: bold\">fi<\/span>\r\n<span style=\"color: #204a87; font-weight: bold\">    fi<\/span>\r\n<span style=\"color: #204a87; font-weight: bold\">done<\/span> &lt; <span style=\"color: #4e9a06\">&quot;$PWD\/$1&quot;<\/span>\r\n<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>A bash script to randomize the xterm colors defined in the .Xresources file. Requirements: An original .Xresources file. It must, among other definitions, specify all the neccesary colors in the following form (order is irrellevant): xterm*color0 : #151503 xterm*color1 : #843706 xterm*color2 : #69750e &#8230; xterm*color15 : #f4dfd8 xterm*background : #211d22 Usage: Navigate to the [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,1],"tags":[162,164,165,41,161,163],"class_list":["post-1587","post","type-post","status-publish","format-standard","hentry","category-linux-stuff","category-nedoloceno","tag-bash","tag-color","tag-script","tag-terminal","tag-xresurces","tag-xterm"],"_links":{"self":[{"href":"https:\/\/blog.spanger.org\/index.php?rest_route=\/wp\/v2\/posts\/1587","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.spanger.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.spanger.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.spanger.org\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.spanger.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1587"}],"version-history":[{"count":95,"href":"https:\/\/blog.spanger.org\/index.php?rest_route=\/wp\/v2\/posts\/1587\/revisions"}],"predecessor-version":[{"id":1692,"href":"https:\/\/blog.spanger.org\/index.php?rest_route=\/wp\/v2\/posts\/1587\/revisions\/1692"}],"wp:attachment":[{"href":"https:\/\/blog.spanger.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.spanger.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.spanger.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}