forked from nushell/nu_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
python_index_table.nu
39 lines (35 loc) · 1.17 KB
/
python_index_table.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# This is the python script
# import sys
# for i in range(0, 16):
# for j in range(0, 16):
# code = str(i * 16 + j)
# sys.stdout.write(u"\u001b[38;5;" + code + "m " + code.ljust(4))
# print u"\u001b[0m"
# Convert anything that's piped into it a string
def 'to str' [] {
each { build-string $it } | str collect
}
# Foreground Colors
echo 0..16 | each {
let i = $it
let row = $(echo 0..16 | each {
let j = $it
let code = $(= $i * 16 + $j)
if $code < 256 {
echo [$(ansi -e '38;5;') $(echo $code | to str) 'm' $(echo $code | to str | str lpad -l 4 -c ' ')] | str collect
} {} # Do nothing in the else
} | str collect)
echo [$row $(char newline)] | str collect
} | str collect
# Background Colors
echo 0..16 | each {
let i = $it
let row = $(echo 0..16 | each {
let j = $it
let code = $(= $i * 16 + $j)
if $code < 256 {
echo [$(ansi -e '48;5;') $(echo $code | to str) 'm' $(echo $code | to str | str lpad -l 4 -c ' ') $(ansi reset)] | str collect
} {} # do nothing in the else
} | str collect)
echo [$row $(char newline)] | str collect
} | str collect