#!/bin/sh # Display available ANSI (terminal) colour combinations # License: LGPLv2 # Author: # http://www.pixelbeat.org/docs/terminal_colours/ # Changes: # V0.1, 24 Apr 2008, Initial release # V0.2, 30 Oct 2009, Support dash # V0.4, 17 May 2011 # http://github.com/pixelb/scripts/commits/master/scripts/ansi_colours.sh global e := '"\033['" global vline := $[tput smacs !2 >/dev/null; printf 'x'; tput rmacs !2 >/dev/null] test $vline = "x" && global vline := '"|'" #printf "${e}4m%80s${e}0m\n" printf "$(e)1;4mf\\\\b$(e)0m$(e)4m none white black red \ green yellow blue magenta cyan $(e)0m\\n" global rows := ''brgybmcw'' for f in [0 7 $[seq 6]] { global no := ''""; global bo := ''""; global p := ''"" for b in [n 7 0 $[seq 6]] { global co := ""3$f""; test $b = n || global co := ""$co;4$b"" global no := ""$(no)$(e)$(co)m $(p)$(co) $(e)0m"" global bo := ""$(bo)$(e)1;$(co)m$(p)1;$(co) $(e)0m"" global p := '" '" } global fc := $[echo $rows | cut -c$(f+1)] printf "$fc $vline$no\nb$fc$vline$bo\n" } (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:e) op: Equal rhs: {(DQ (EscapedLiteralPart token:) ("33["))} spids: [33] ) ] spids: [33] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:vline) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Sentence child: (SimpleCommand words: [{(tput)} {(smacs)}] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [45] ) ] ) terminator: ) (Sentence child: (C {(printf)} {(SQ )}) terminator: ) (SimpleCommand words: [{(tput)} {(rmacs)}] redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[60])] ) ] ) left_token: spids: [40 62] ) } spids: [39] ) ] spids: [39] ) (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$vline"))} {(Lit_Other "=")} {(DQ (x))} {(Lit_Other "]")}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:vline) op:Equal rhs:{(DQ ("|"))} spids:[80])] spids: [80] ) ] op_id: Op_DAmp ) (C {(printf)} { (DQ (${ VSub_Name e) ("1;4mf") (EscapedLiteralPart token:) (EscapedLiteralPart token:) (b) (${ VSub_Name e) (0m) (${ VSub_Name e) ("4m none white black red ") ("green yellow blue magenta cyan ") (${ VSub_Name e) (0m) (EscapedLiteralPart token:) (n) ) } ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:rows) op:Equal rhs:{(SQ )} spids:[118])] spids: [118] ) (ForEach iter_name: f iter_words: [ {(0)} {(7)} { (CommandSubPart command_list: (CommandList children:[(C {(seq)} {(6)})]) left_token: spids: [134 138] ) } ] do_arg_iter: False body: (DoGroup children: [ (Sentence child: (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:no) op:Equal rhs:{(DQ )} spids:[144])] spids: [144] ) terminator: ) (Sentence child: (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:bo) op:Equal rhs:{(DQ )} spids:[149])] spids: [149] ) terminator: ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:p) op:Equal rhs:{(DQ )} spids:[154])] spids: [154] ) (ForEach iter_name: b iter_words: [ {(n)} {(7)} {(0)} { (CommandSubPart command_list: (CommandList children:[(C {(seq)} {(6)})]) left_token: spids: [171 175] ) } ] do_arg_iter: False body: (DoGroup children: [ (Sentence child: (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:co) op: Equal rhs: {(DQ (3) ($ VSub_Name "$f"))} spids: [181] ) ] spids: [181] ) terminator: ) (AndOr children: [ (C {(Lit_Other "[")} {($ VSub_Name "$b")} {(Lit_Other "=")} {(n)} {(Lit_Other "]")} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:co) op: Equal rhs: {(DQ ($ VSub_Name "$co") (";4") ($ VSub_Name "$b"))} spids: [200] ) ] spids: [200] ) ] op_id: Op_DPipe ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:no) op: Equal rhs: { (DQ (${ VSub_Name no) (${ VSub_Name e) (${ VSub_Name co) ("m ") (${ VSub_Name p) (${ VSub_Name co) (" ") (${ VSub_Name e) (0m) ) } spids: [208] ) ] spids: [208] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:bo) op: Equal rhs: { (DQ (${ VSub_Name bo) (${ VSub_Name e) ("1;") (${ VSub_Name co) (m) (${ VSub_Name p) ("1;") (${ VSub_Name co) (" ") (${ VSub_Name e) (0m) ) } spids: [234] ) ] spids: [234] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:p) op: Equal rhs: {(DQ (" "))} spids: [262] ) ] spids: [262] ) ] spids: [178 268] ) spids: [164 176] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:fc) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {($ VSub_Name "$rows")}) (C {(cut)} {(-c) (ArithSubPart anode: (ArithBinary op_id: Arith_Plus left: (ArithVarRef name:f) right: (ArithWord w:{(Lit_Digits 1)}) ) spids: [282 287] ) } ) ] negated: False ) ] ) left_token: spids: [272 288] ) } spids: [271] ) ] spids: [271] ) (C {(printf)} { (DQ ($ VSub_Name "$fc") (" ") ($ VSub_Name "$vline") ($ VSub_Name "$no") (EscapedLiteralPart token:) (b) ($ VSub_Name "$fc") ($ VSub_Name "$vline") ($ VSub_Name "$bo") (EscapedLiteralPart token:) ) } ) ] spids: [141 306] ) spids: [129 139] ) ] )