mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
Merge pull request #2 from fdncred/fdncred_scripts
added fdncred's scripts
This commit is contained in:
commit
386d308f8a
24 changed files with 882 additions and 0 deletions
21
256-color.sh
Executable file
21
256-color.sh
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This program is free software. It comes without any warranty, to
|
||||||
|
# the extent permitted by applicable law. You can redistribute it
|
||||||
|
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||||
|
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||||
|
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||||
|
|
||||||
|
for fgbg in 38 48 ; do # Foreground / Background
|
||||||
|
for color in {0..255} ; do # Colors
|
||||||
|
# Display the color
|
||||||
|
printf "\e[${fgbg};5;%sm %3s \e[0m" $color $color
|
||||||
|
# Display 6 colors per lines
|
||||||
|
if [ $((($color + 1) % 6)) == 4 ] ; then
|
||||||
|
echo # New line
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo # New line
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
22
color_and_formatting.sh
Executable file
22
color_and_formatting.sh
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This program is free software. It comes without any warranty, to
|
||||||
|
# the extent permitted by applicable law. You can redistribute it
|
||||||
|
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||||
|
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||||
|
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||||
|
|
||||||
|
#Background
|
||||||
|
for clbg in {40..47} {100..107} 49 ; do
|
||||||
|
#Foreground
|
||||||
|
for clfg in {30..37} {90..97} 39 ; do
|
||||||
|
#Formatting
|
||||||
|
for attr in 0 1 2 4 5 7 ; do
|
||||||
|
#Print the result
|
||||||
|
echo -en "\033[${attr};${clbg};${clfg}m ^[${attr};${clbg};${clfg}m \033[0m"
|
||||||
|
done
|
||||||
|
echo #Newline
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
88
color_table.nu
Normal file
88
color_table.nu
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
def make_header [hi] {
|
||||||
|
if $hi == $true {
|
||||||
|
let ansi100m = $(echo '100m' | str lpad -l 11 -c ' ')
|
||||||
|
let ansi101m = $(echo '101m' | str lpad -l 9 -c ' ')
|
||||||
|
let ansi102m = $(echo '102m' | str lpad -l 9 -c ' ')
|
||||||
|
let ansi103m = $(echo '103m' | str lpad -l 9 -c ' ')
|
||||||
|
let ansi104m = $(echo '104m' | str lpad -l 9 -c ' ')
|
||||||
|
let ansi105m = $(echo '105m' | str lpad -l 9 -c ' ')
|
||||||
|
let ansi106m = $(echo '106m' | str lpad -l 9 -c ' ')
|
||||||
|
let ansi107m = $(echo '107m' | str lpad -l 9 -c ' ')
|
||||||
|
echo [$(char newline) $ansi100m $ansi101m $ansi102m $ansi103m $ansi104m $ansi105m $ansi106m $ansi107m $(char newline)] | str collect
|
||||||
|
} {
|
||||||
|
let ansi40m = $(echo '40m' | str lpad -l 10 -c ' ')
|
||||||
|
let ansi41m = $(echo '41m' | str lpad -l 8 -c ' ')
|
||||||
|
let ansi42m = $(echo '42m' | str lpad -l 8 -c ' ')
|
||||||
|
let ansi43m = $(echo '43m' | str lpad -l 8 -c ' ')
|
||||||
|
let ansi44m = $(echo '44m' | str lpad -l 8 -c ' ')
|
||||||
|
let ansi45m = $(echo '45m' | str lpad -l 8 -c ' ')
|
||||||
|
let ansi46m = $(echo '46m' | str lpad -l 8 -c ' ')
|
||||||
|
let ansi47m = $(echo '47m' | str lpad -l 8 -c ' ')
|
||||||
|
echo [$(char newline) $ansi40m $ansi41m $ansi42m $ansi43m $ansi44m $ansi45m $ansi46m $ansi47m $(char newline)] | str collect
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# mk_header and make_header do the same thing in different ways
|
||||||
|
# make_header is far easier to read and understand
|
||||||
|
# mk_header is more convoluted but less repetitive
|
||||||
|
|
||||||
|
def mk_header [color_range:range] {
|
||||||
|
let min_rng = $(echo $color_range | math min)
|
||||||
|
let hi_start_pad = 11
|
||||||
|
let hi_regular_pad = 9
|
||||||
|
let lo_start_pad = 10
|
||||||
|
let lo_regular_pad = 8
|
||||||
|
echo $color_range | each {
|
||||||
|
let ansi_color = $(echo [$(build-string $it 'm')])
|
||||||
|
if $it == $min_rng {
|
||||||
|
if $min_rng == 100 {
|
||||||
|
let header = $(echo $ansi_color | str lpad -l $hi_start_pad -c ' ')
|
||||||
|
echo $header
|
||||||
|
} {
|
||||||
|
let header = $(echo $ansi_color | str lpad -l $lo_start_pad -c ' ')
|
||||||
|
echo $header
|
||||||
|
}
|
||||||
|
} {
|
||||||
|
if $min_rng >= 100 {
|
||||||
|
let header = $(echo $ansi_color | str lpad -l $hi_regular_pad -c ' ')
|
||||||
|
echo $header
|
||||||
|
} {
|
||||||
|
let header = $(echo $ansi_color | str lpad -l $lo_regular_pad -c ' ')
|
||||||
|
echo $header
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} | str collect
|
||||||
|
echo $(char newline)
|
||||||
|
}
|
||||||
|
|
||||||
|
def color_row_range [num:int bg_rg:range] {
|
||||||
|
let reset = $(ansi reset)
|
||||||
|
let row_header = $(build-string $num "m " $(ansi reset))
|
||||||
|
let row_data = $(echo $bg_rg | each {
|
||||||
|
let row_name = $(echo [$(build-string $num ';' $it) "m"] | str collect)
|
||||||
|
let ansi_color = $(ansi -e $row_name)
|
||||||
|
echo [$ansi_color ' ' $row_name ' ' $reset] | str collect
|
||||||
|
} | append $(char newline) | str collect)
|
||||||
|
echo [$row_header $row_data] | str collect
|
||||||
|
}
|
||||||
|
|
||||||
|
def create_color_tables [fg_range:range bg_range:range] {
|
||||||
|
echo $fg_range | each {
|
||||||
|
color_row_range $it $bg_range
|
||||||
|
} | str collect
|
||||||
|
}
|
||||||
|
|
||||||
|
def color_table [] {
|
||||||
|
#make_header $false
|
||||||
|
mk_header 40..47
|
||||||
|
create_color_tables 30..37 40..47
|
||||||
|
|
||||||
|
# put a line between tables
|
||||||
|
echo $(char newline)
|
||||||
|
|
||||||
|
#make_header $true
|
||||||
|
mk_header 100..107
|
||||||
|
create_color_tables 90..97 100..107
|
||||||
|
}
|
||||||
|
|
||||||
|
color_table
|
25
color_tables.nu
Normal file
25
color_tables.nu
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Bash script
|
||||||
|
# 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
|
||||||
|
# echo
|
||||||
|
# done
|
||||||
|
# echo ""
|
||||||
|
|
||||||
|
echo 0..8 | each {
|
||||||
|
let x = $it
|
||||||
|
let row = $(echo 30..37 | each {
|
||||||
|
let i = $it
|
||||||
|
let row = $(echo 40..47 | each {
|
||||||
|
let a = $it
|
||||||
|
let color = $(build-string $x ';' $i ';' $a 'm')
|
||||||
|
echo [$(ansi -e $color) $color $(ansi reset) ' ']
|
||||||
|
} | str collect)
|
||||||
|
echo [$row $(char newline)] | str collect
|
||||||
|
} | str collect)
|
||||||
|
echo [$row $(char newline)] | str collect
|
||||||
|
} | str collect
|
12
color_tables.sh
Normal file
12
color_tables.sh
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
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
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
echo ""
|
25
colors.sh
Normal file
25
colors.sh
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# This is slightly altered from the original which is found here:
|
||||||
|
# http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
|
||||||
|
#
|
||||||
|
# Each line is the color code of one foreground color, out of 17
|
||||||
|
# (default + 16 escapes), followed by a test use of that color
|
||||||
|
# on all nine background colors (default + 8 escapes).
|
||||||
|
#
|
||||||
|
|
||||||
|
text="xYz"; # Some test text
|
||||||
|
|
||||||
|
echo -e "\n 40m 41m 42m 43m 44m 45m 46m 47m";
|
||||||
|
|
||||||
|
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
|
||||||
|
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
|
||||||
|
' 36m' '1;36m' ' 37m' '1;37m'; do
|
||||||
|
FG=${FGs// /}
|
||||||
|
echo -en " $FGs \033[$FG ${text} ";
|
||||||
|
for BG in 40m 41m 42m 43m 44m 45m 46m 47m; do
|
||||||
|
echo -en "$EINS \033[$FG\033[${BG} ${text} \033[0m";
|
||||||
|
done
|
||||||
|
echo;
|
||||||
|
done
|
||||||
|
echo;
|
5
demo.nu
Normal file
5
demo.nu
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
def my-ls [x] {
|
||||||
|
ls $x | where size > 10kb
|
||||||
|
}
|
||||||
|
|
||||||
|
my-ls .
|
40
gradient.nu
Normal file
40
gradient.nu
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# this script will print a blue gradient on the screen
|
||||||
|
|
||||||
|
let height = 40 # really need to get the terminal height here
|
||||||
|
let width = 160 # really need to get the terminal width here
|
||||||
|
|
||||||
|
seq 0 $height | each {
|
||||||
|
let row_data = $(seq 0 $width | each {
|
||||||
|
let fgcolor = $(iter_inc 2 2 $(echo $it | str to-int))
|
||||||
|
if $fgcolor > 200 && $fgcolor < 210 {
|
||||||
|
echo [$(ansi -e '48;2;0;0;') $(build-string $fgcolor m) 'Nu' $(ansi -e '0m')] | str collect
|
||||||
|
} {
|
||||||
|
echo [$(ansi -e '48;2;0;0;') $(build-string $fgcolor m) ' ' $(ansi -e '0m')] | str collect
|
||||||
|
}
|
||||||
|
} | str collect)
|
||||||
|
echo [$row_data $(char newline)] | str collect | autoview
|
||||||
|
} | str collect
|
||||||
|
|
||||||
|
def iter_inc [incr mult iter] {
|
||||||
|
# echo $(build-string $incr + $mult * $iter) | math eval | math round
|
||||||
|
= $incr + $mult * $iter
|
||||||
|
}
|
||||||
|
|
||||||
|
# ╭────┬────────────────────┬──────────────────────────────────────────────────────────────────────────────────────╮
|
||||||
|
# │ # │ key │ value │
|
||||||
|
# ├────┼────────────────────┼──────────────────────────────────────────────────────────────────────────────────────┤
|
||||||
|
# │ 0 │ version │ 0.25.2 │
|
||||||
|
# │ 1 │ branch │ main │
|
||||||
|
# │ 2 │ short_commit │ d06f457b │
|
||||||
|
# │ 3 │ commit_hash │ d06f457b2a7dee3acc71ecd0dc8b6a34afbfc5d8 │
|
||||||
|
# │ 4 │ commit_date │ 2021-01-11 22:59:53 │
|
||||||
|
# │ 5 │ build_os │ windows-x86_64 │
|
||||||
|
# │ 6 │ rust_version │ rustc 1.49.0 (e1884a8e3 2020-12-29) │
|
||||||
|
# │ 7 │ rust_channel │ stable (default) │
|
||||||
|
# │ 8 │ cargo_version │ cargo 1.49.0 (d00d64df9 2020-12-05) │
|
||||||
|
# │ 9 │ pkg_version │ 0.25.2 │
|
||||||
|
# │ 10 │ build_time │ 2021-01-12 07:29:22 │
|
||||||
|
# │ 11 │ build_rust_channel │ release │
|
||||||
|
# │ 12 │ features │ clipboard-cli, ctrlc, default, directories, dirs, git, ichwh, ptree, rich-benchmark, │
|
||||||
|
# │ │ │ rustyline, term, trash, uuid, which, zip │
|
||||||
|
# ╰────┴────────────────────┴──────────────────────────────────────────────────────────────────────────────────────╯
|
27
gradient.ps1
Normal file
27
gradient.ps1
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
function Set-Cursor {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param ([int] $x, [int] $y)
|
||||||
|
$Host.UI.RawUI.CursorPosition = @{x = $x; y = $y }
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-Character {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param ([int]$index)
|
||||||
|
$mystring = ' Trevor Sullivan'
|
||||||
|
return $index -ge ($mystring.Length) ? ' ' : $mystring[$index]
|
||||||
|
}
|
||||||
|
|
||||||
|
function main {
|
||||||
|
|
||||||
|
for ($y = 0; $y -le ($host.ui.RawUI.BufferSize.Height - 1); $y++) {
|
||||||
|
$Color = 25
|
||||||
|
Set-Cursor -x $PSItem -y $y
|
||||||
|
0..($Host.UI.RawUI.BufferSize.Width - 1) | ForEach-Object {
|
||||||
|
Write-Host -Object ("`e[48;2;0;0;$Color`m{0}" -f (Get-Character -Index $PSItem)) -NoNewline
|
||||||
|
$Color += 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Start-Sleep -Seconds 5
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
11
inner_outer_loop.nu
Normal file
11
inner_outer_loop.nu
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# This is an experiment to see if one can have
|
||||||
|
# $it in and inner loop and an outer loop at
|
||||||
|
# the same time, each having different values
|
||||||
|
|
||||||
|
seq 30 39 | each {
|
||||||
|
let row = $(echo [$it ' '] | str collect)
|
||||||
|
let data = $(seq 40 49 | each {
|
||||||
|
echo [$it ' '] | str collect
|
||||||
|
} | str collect)
|
||||||
|
echo [$row $data $(char newline)] | str collect
|
||||||
|
} | str collect
|
29
myprompt.nu
Normal file
29
myprompt.nu
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# This is a work in progress. Not working yet but you can see where I'm going.
|
||||||
|
let decorator = '#'
|
||||||
|
let machine_name = $(sys | get host.hostname)
|
||||||
|
let current_dir = $(pwd)
|
||||||
|
let git_info = $(do -i { git rev-parse --abbrev-ref HEAD } | str trim | str collect )
|
||||||
|
let title_bar = $(set_title)
|
||||||
|
let git_status = $(git -c core.quotepath=false -c color.status=false status -uall --short --branch)
|
||||||
|
|
||||||
|
|
||||||
|
# Get Git Info custom commands
|
||||||
|
|
||||||
|
def git_br [] {
|
||||||
|
echo [ $(ansi gb) $(pwd) $(ansi reset) '(' $(ansi cb) $(do -i { git rev-parse --abbrev-ref HEAD } | str trim | str collect ) $(ansi reset) ')' $(char newline) $(ansi yb) $(date now | date format '%m/%d/%Y %I:%M:%S%.3f %p') $(ansi reset) ' ¯\\_(ツ)_/¯ ' $(char prompt) ' '] | str collect
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set Title String custom commands
|
||||||
|
|
||||||
|
def set_title_str [str-arg] {
|
||||||
|
echo [$(ansi title) ' ' $str-arg ' ' $(ansi bel)] | str collect
|
||||||
|
}
|
||||||
|
def get_abbrev_pwd_win [] {
|
||||||
|
echo [$(pwd | split row '\\' | first $(pwd | split row '\\' | count | each {= $it - 1} ) | str substring '0,1' | format '{$it}/' | append $(pwd | split row '\\' | last ) | str collect)] | str collect
|
||||||
|
}
|
||||||
|
def get_abbrev_pwd_lin [] {
|
||||||
|
echo [$(pwd | split row '/' | first $(pwd | split row '/' | count | each {= $it - 1} ) | each { str substring '0,1' | format '{$it}/' } | append $(pwd | split row '/' | last ) | str collect)] | str collect
|
||||||
|
}
|
||||||
|
def set_title [] {
|
||||||
|
set_title_str $(echo $(get_abbrev_pwd_win))
|
||||||
|
}
|
19
nu_index_bg.nu
Normal file
19
nu_index_bg.nu
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
def show_index_colors [] {
|
||||||
|
let prefix = "48;5;"
|
||||||
|
let relet_color = "0m"
|
||||||
|
echo 1..256 | each {
|
||||||
|
let cr = $(echo $(build-string $it % 16) | math eval)
|
||||||
|
let color = $(echo [$(ansi -e $prefix) $(build-string $it) 'm'] | str collect)
|
||||||
|
let padded_number = $(echo $(build-string $it | str lpad -l 3 -c '0'))
|
||||||
|
if $cr == 0 {
|
||||||
|
echo [$color $padded_number ' ' $(ansi -e $relet_color) $(char newline)]
|
||||||
|
} {
|
||||||
|
echo [$color $padded_number ' ' $(ansi -e $relet_color)]
|
||||||
|
}
|
||||||
|
} | str collect
|
||||||
|
}
|
||||||
|
|
||||||
|
show_index_colors
|
||||||
|
|
||||||
|
#one-liner
|
||||||
|
#echo 0..255 | each {echo [$(ansi -e '38;5;') $(build-string $it) 'm' $(build-string $it) ' ']} | str collect
|
16
nu_index_fg.nu
Normal file
16
nu_index_fg.nu
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
def show_index_colors [] {
|
||||||
|
let prefix = "38;5;"
|
||||||
|
echo 1..256 | each {
|
||||||
|
let cr = $(echo $(build-string $it % 16) | math eval)
|
||||||
|
if $cr == 0 {
|
||||||
|
echo [$(ansi -e $prefix) $(build-string $it) 'm' $(build-string $it | str lpad -l 3 -c '0') ' ' $(char newline)]
|
||||||
|
} {
|
||||||
|
echo [$(ansi -e $prefix) $(build-string $it) 'm' $(build-string $it | str lpad -l 3 -c '0') ' ']
|
||||||
|
}
|
||||||
|
} | str collect
|
||||||
|
}
|
||||||
|
|
||||||
|
show_index_colors
|
||||||
|
|
||||||
|
#one-liner
|
||||||
|
#echo 0..255 | each {echo [$(ansi -e '38;5;') $(build-string $it) 'm' $(build-string $it) ' ']} | str collect
|
24
nu_index_fg2.nu
Normal file
24
nu_index_fg2.nu
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# this script uses foreground ansi index colors to print
|
||||||
|
# a table of 16 rows by 16 colums where each item is a
|
||||||
|
# different color
|
||||||
|
def show_index_colors [] {
|
||||||
|
let prefix = "38;5;"
|
||||||
|
echo 1..256 | each {
|
||||||
|
let cr = $(echo $(build-string $it % 16) | math eval)
|
||||||
|
let color = $(echo [$(ansi -e $prefix) $(build-string $it) 'm'] | str collect)
|
||||||
|
let padded_number = $(echo $(build-string $it | str lpad -l 3 -c '0'))
|
||||||
|
if $cr == 0 {
|
||||||
|
echo [$color $padded_number ' ' $(char newline)]
|
||||||
|
} {
|
||||||
|
echo [$color $padded_number ' ']
|
||||||
|
}
|
||||||
|
} | str collect
|
||||||
|
}
|
||||||
|
|
||||||
|
show_index_colors
|
||||||
|
|
||||||
|
# one-liner version that just prints
|
||||||
|
# it all on one line which wraps in
|
||||||
|
# your terminal
|
||||||
|
|
||||||
|
#echo 1..256 | each {echo [$(ansi -e '38;5;') $(build-string $it) 'm' $(build-string $it) ' ']} | str collect
|
110
nu_style.nu
Normal file
110
nu_style.nu
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
# This is a port of powershells $psstyle
|
||||||
|
# found here https://github.com/PowerShell/PowerShell/blob/5f3dd938b792e1a395fd011ac1461246db7c0e1f/src/System.Management.Automation/FormatAndOutput/common/PSStyle.cs
|
||||||
|
|
||||||
|
# Example Usage
|
||||||
|
# echo $(fg_blue) Darren $(relet) ' ' Schroeder | str collect
|
||||||
|
# More examples in the short_list.nu script
|
||||||
|
|
||||||
|
alias fmt_error = ansi -e '31;1m'
|
||||||
|
alias fmt_warning = ansi -e '33;1m'
|
||||||
|
alias fmt_verbose = ansi -e '33;1m'
|
||||||
|
alias fmt_debug = ansi -e '33;1m'
|
||||||
|
alias fmt_format_accent = ansi -e '32;1m'
|
||||||
|
alias fmt_error_accent = ansi -e '36;1m'
|
||||||
|
|
||||||
|
alias relet = ansi -e '0m' # really reset but there are external commands for reset already
|
||||||
|
alias blink_off = ansi -e '25m'
|
||||||
|
alias blink_on = ansi -e '5m'
|
||||||
|
alias bold_off = ansi -e '22m'
|
||||||
|
alias bold_on = ansi -e '1m'
|
||||||
|
alias hidden_on = ansi -e '8m'
|
||||||
|
alias hidden_off = ansi -e '28m'
|
||||||
|
alias reverse_on = ansi -e '7m'
|
||||||
|
alias reverse_off = ansi -e '27m'
|
||||||
|
alias italic_off = ansi -e '23m'
|
||||||
|
alias italic_on = ansi -e '3m'
|
||||||
|
alias underline_off = ansi -e '24m'
|
||||||
|
alias underline_on = ansi -e '4m'
|
||||||
|
alias strikethrough_off = ansi -e '29m'
|
||||||
|
alias strikethrough_on = ansi -e '9m'
|
||||||
|
|
||||||
|
# this doesn't work right. i need to have an $(ansi escape) defined but i don't think there is one
|
||||||
|
#def format_hyperlink [link text] {echo [$(ansi -o '8;;') $link '\' $text $(ansi -o '8;;') '\'] | str collect }
|
||||||
|
|
||||||
|
alias fg_black = ansi -e '30m'
|
||||||
|
alias fg_red = ansi -e '31m'
|
||||||
|
alias fg_green = ansi -e '32m'
|
||||||
|
alias fg_yellow = ansi -e '33m'
|
||||||
|
alias fg_blue = ansi -e '34m'
|
||||||
|
alias fg_magenta = ansi -e '35m'
|
||||||
|
alias fg_purple = ansi -e '35m'
|
||||||
|
alias fg_cyan = ansi -e '36m'
|
||||||
|
alias fg_white = ansi -e '37m'
|
||||||
|
|
||||||
|
alias fg_dark_gray = ansi -e '90m'
|
||||||
|
alias fg_light_black = ansi -e '90m'
|
||||||
|
alias fg_light_red = ansi -e '91m'
|
||||||
|
alias fg_light_green = ansi -e '92m'
|
||||||
|
alias fg_light_yellow = ansi -e '93m'
|
||||||
|
alias fg_light_blue = ansi -e '94m'
|
||||||
|
alias fg_light_magenta = ansi -e '95m'
|
||||||
|
alias fg_light_purple = ansi -e '95m'
|
||||||
|
alias fg_light_cyan = ansi -e '96m'
|
||||||
|
alias fg_light_gray = ansi -e '97m'
|
||||||
|
alias fg_light_white = ansi -e '97m'
|
||||||
|
|
||||||
|
# construct a rgb foreground color
|
||||||
|
def fg_from_rgb [
|
||||||
|
red:int # red component 0-255
|
||||||
|
green:int # green component 0-255
|
||||||
|
blue:int # blue component 0-255
|
||||||
|
] {
|
||||||
|
echo [$(ansi -e '38;2;') $red ';' $green ';' $blue 'm'] | str collect
|
||||||
|
}
|
||||||
|
|
||||||
|
alias bg_black = ansi -e '40m'
|
||||||
|
alias bg_red = ansi -e '41m'
|
||||||
|
alias bg_green = ansi -e '42m'
|
||||||
|
alias bg_yellow = ansi -e '43m'
|
||||||
|
alias bg_blue = ansi -e '44m'
|
||||||
|
alias bg_magenta = ansi -e '45m'
|
||||||
|
alias bg_purple = ansi -e '45m'
|
||||||
|
alias bg_cyan = ansi -e '46m'
|
||||||
|
alias bg_white = ansi -e '47m'
|
||||||
|
|
||||||
|
alias bg_dark_gray = ansi -e '100m'
|
||||||
|
alias bg_light_black = ansi -e '100m'
|
||||||
|
alias bg_light_red = ansi -e '101m'
|
||||||
|
alias bg_light_green = ansi -e '102m'
|
||||||
|
alias bg_light_yellow = ansi -e '103m'
|
||||||
|
alias bg_light_magenta = ansi -e '105m'
|
||||||
|
alias bg_light_purple = ansi -e '105m'
|
||||||
|
alias bg_light_blue = ansi -e '104m'
|
||||||
|
alias bg_light_cyan = ansi -e '106m'
|
||||||
|
alias bg_light_gray = ansi -e '107m'
|
||||||
|
alias bg_light_white = ansi -e '107m'
|
||||||
|
|
||||||
|
alias bg_expand = ansi -e 'K'
|
||||||
|
|
||||||
|
# construct a rgb background color
|
||||||
|
def bg_from_rgb [
|
||||||
|
red:int # red component 0-255
|
||||||
|
green:int # green component 0-255
|
||||||
|
blue:int # blue component 0-255
|
||||||
|
] {
|
||||||
|
echo [$(ansi -e '48;2;') $red ';' $green ';' $blue 'm'] | str collect
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get a foreground color from an index value 0-255
|
||||||
|
def fg_from_index [
|
||||||
|
idx:int # index value 0-255
|
||||||
|
] {
|
||||||
|
echo [$(ansi -e '38;5;') $idx 'm'] | str collect
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get a background color from an index value 0-255
|
||||||
|
def bg_from_index [
|
||||||
|
idx:int # index value 0-255
|
||||||
|
] {
|
||||||
|
echo [$(ansi -e '48;5;') $idx 'm'] | str collect
|
||||||
|
}
|
23
percent_meter.nu
Normal file
23
percent_meter.nu
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
def loading [] {
|
||||||
|
echo Loading $(char newline) | str collect | autoview
|
||||||
|
echo 0..100 | each {
|
||||||
|
sleep 50ms
|
||||||
|
#hide_cursor
|
||||||
|
# I believe '1000D' means move the cursor to the left 1000 columns
|
||||||
|
echo $(ansi -e '1000D') | autoview
|
||||||
|
echo $(build-string $it '%') | autoview
|
||||||
|
}
|
||||||
|
#show_cursor
|
||||||
|
}
|
||||||
|
|
||||||
|
def show_cursor [] {
|
||||||
|
echo $(ansi -e '?25h') | autoview
|
||||||
|
}
|
||||||
|
|
||||||
|
def hide_cursor [] {
|
||||||
|
echo $(ansi -e '?25l') | autoview
|
||||||
|
}
|
||||||
|
|
||||||
|
hide_cursor
|
||||||
|
loading
|
||||||
|
show_cursor
|
17
print.nu
Normal file
17
print.nu
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# Not working yet
|
||||||
|
|
||||||
|
# A print command that concatenates arguments together with an optional separator
|
||||||
|
# By default there will be no newline
|
||||||
|
def print [
|
||||||
|
--separator(-s):any? # Optional separator
|
||||||
|
...rest # All of the parameters
|
||||||
|
] {
|
||||||
|
let is_empty = $(empty? $separator)
|
||||||
|
echo $rest | each {
|
||||||
|
if $is_empty {
|
||||||
|
build-string $it
|
||||||
|
} {
|
||||||
|
build-string $it $separator
|
||||||
|
}
|
||||||
|
} | str collect
|
||||||
|
}
|
39
python_index_table.nu
Normal file
39
python_index_table.nu
Normal file
|
@ -0,0 +1,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
|
33
ref_table.nu
Normal file
33
ref_table.nu
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
# This script will print a table 8 rows by 36 columns
|
||||||
|
# of background colors using ansi index coloring
|
||||||
|
|
||||||
|
# This prints the column headers
|
||||||
|
let nl = $(char newline)
|
||||||
|
let plus = $(echo [$nl ' + '] | str collect)
|
||||||
|
let cols = $(seq 0 35 | each { echo $(build-string $it) | str lpad -c ' ' -l 3 } | str collect)
|
||||||
|
echo [$plus $cols] | str collect
|
||||||
|
|
||||||
|
let ansi_bg = $(ansi -e '48;5;')
|
||||||
|
let ansi_reset = $(ansi reset)
|
||||||
|
echo $nl $nl | str collect
|
||||||
|
|
||||||
|
# This prints the row headers
|
||||||
|
let row_header = ' 0 '
|
||||||
|
let row_data = $(seq 0 15 | each {
|
||||||
|
echo [$ansi_bg $it 'm' ' ' $ansi_reset ' ']
|
||||||
|
} | str collect)
|
||||||
|
echo [$row_header $row_data $nl $nl] | str collect
|
||||||
|
|
||||||
|
# This is the meat of the script that prints the little squares of color
|
||||||
|
seq 0 6 | each {
|
||||||
|
let math_str = $(build-string $it ' * 36 + 16')
|
||||||
|
let i = $(echo $math_str | math eval)
|
||||||
|
let row_header = $(echo $i | str from -d 0 | str lpad -c ' ' -l 4)
|
||||||
|
let row_data = $(seq 0 35 | each {
|
||||||
|
let math_str2 = $(build-string $i + $it)
|
||||||
|
let val = $(echo $math_str2 | math eval | str from -d 0)
|
||||||
|
echo [$ansi_bg $val 'm' ' ' $(ansi -e 'm') ' ']
|
||||||
|
} | str collect)
|
||||||
|
echo [$row_header ' ' $row_data $nl $nl] | str collect
|
||||||
|
} | str collect
|
||||||
|
|
43
sample.nu
Normal file
43
sample.nu
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
# Background Colors
|
||||||
|
echo 40..47 100..107 49 | each {
|
||||||
|
let clbg = $it
|
||||||
|
# Foreground Colors
|
||||||
|
echo 30..37 90..97 39 | each {
|
||||||
|
let clfg = $it
|
||||||
|
# 0 Normal
|
||||||
|
# 1 Bold or increased intensity
|
||||||
|
# 2 Faint or decreased intensity
|
||||||
|
# 3 Italic (not widely supported)
|
||||||
|
# 4 Underline
|
||||||
|
# 5 Slow Blink < 150 per minute
|
||||||
|
# 6 Rapid Blink > 150 per minute
|
||||||
|
# 7 Reverse Video
|
||||||
|
# 8 Conceal (not widely supported)
|
||||||
|
# 9 Strike-through
|
||||||
|
let row = $(echo 0..9 | each {
|
||||||
|
let attr = $it
|
||||||
|
let ansi_str = $(echo [$(make-str $attr) ';' $(make-str $clbg) ';' $(make-str $clfg) 'm'] | str collect)
|
||||||
|
echo [$(ansi -e $ansi_str) ' ' $ansi_str ' ' $(ansi reset)] | str collect
|
||||||
|
} | str collect)
|
||||||
|
echo [$row $(char newline)] | str collect | autoview
|
||||||
|
} | str collect
|
||||||
|
} | str collect
|
||||||
|
|
||||||
|
def make-str [item] {
|
||||||
|
echo $item | str from
|
||||||
|
}
|
||||||
|
|
||||||
|
# Bash Script
|
||||||
|
# for clbg in {40..47} {100..107} 49 ; do
|
||||||
|
# #Foreground
|
||||||
|
# for clfg in {30..37} {90..97} 39 ; do
|
||||||
|
# #Formatting
|
||||||
|
# for attr in 0 1 2 4 5 7 ; do
|
||||||
|
# #Print the result
|
||||||
|
# echo -en "\033[${attr};${clbg};${clfg}m ^[${attr};${clbg};${clfg}m \033[0m"
|
||||||
|
# done
|
||||||
|
# echo #Newline
|
||||||
|
# done
|
||||||
|
# done
|
||||||
|
|
||||||
|
# exit 0
|
18
sample_andres.json
Normal file
18
sample_andres.json
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "Brunello Cucinelli",
|
||||||
|
"shoes": [
|
||||||
|
{ "name": "tasselled black low-top lace-up", "price": 1000 },
|
||||||
|
{ "name": "tasselled green low-top lace-up", "price": 1100 },
|
||||||
|
{ "name": "plain beige suede moccasin", "price": 950 },
|
||||||
|
{ "name": "plain olive suede moccasin", "price": 1050 }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Gucci",
|
||||||
|
"shoes": [
|
||||||
|
{ "name": "red leather laced sneakers", "price": 800 },
|
||||||
|
{ "name": "black leather laced sneakers", "price": 900 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
22
sample_andres.nu
Normal file
22
sample_andres.nu
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
def look_for [word] {
|
||||||
|
open sample_andres.json |
|
||||||
|
flatten |
|
||||||
|
flatten |
|
||||||
|
insert comp {
|
||||||
|
get shoes_name |
|
||||||
|
split row " " |
|
||||||
|
each --numbered {
|
||||||
|
= [[idx, loc]; [$it.index, $(= $it.item | str index-of $word)]]
|
||||||
|
}
|
||||||
|
} |
|
||||||
|
flatten |
|
||||||
|
flatten |
|
||||||
|
where comp.loc >= 0 |
|
||||||
|
flatten |
|
||||||
|
update idx { = $it.idx + 1 } |
|
||||||
|
reject name price loc |
|
||||||
|
rename nameWords targetWordIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
look_for "leather" | to json --pretty 4
|
||||||
|
look_for "low-top" | to json --pretty 4
|
189
short_list.nu
Normal file
189
short_list.nu
Normal file
|
@ -0,0 +1,189 @@
|
||||||
|
source nu_style.nu
|
||||||
|
|
||||||
|
# # Regular Colors
|
||||||
|
echo ' Regular Colors' $(char newline) $(char newline) | str collect
|
||||||
|
# | Value | Color |
|
||||||
|
# | -------- | ------ |
|
||||||
|
# | \e[0;30m | Black |
|
||||||
|
# | \e[0;31m | Red |
|
||||||
|
# | \e[0;32m | Green |
|
||||||
|
# | \e[0;33m | Yellow |
|
||||||
|
# | \e[0;34m | Blue |
|
||||||
|
# | \e[0;35m | Purple |
|
||||||
|
# | \e[0;36m | Cyan |
|
||||||
|
# | \e[0;37m | White |
|
||||||
|
echo '| Value | Color | Name |' $(char newline) | str collect
|
||||||
|
echo '| ----- | ----- | --------- |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_black) ' 0;30m ' $(relet) '| ' Black ' | fg_black |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_red) ' 0;31m ' $(relet) '| ' Red ' | fg_red |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_green) ' 0;32m ' $(relet) '| ' Green ' | fg_green |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_yellow) ' 0;33m ' $(relet) '| ' Yellow ' | fg_yellow |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_blue) ' 0;34m ' $(relet) '| ' Blue ' | fg_blue |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_purple) ' 0;35m ' $(relet) '| ' Purple ' | fg_purple |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_cyan) ' 0;36m ' $(relet) '| ' Cyan ' | fg_cyan |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_white) ' 0;37m ' $(relet) '| ' White ' | fg_white |' $(char newline) | str collect
|
||||||
|
echo $(char newline)
|
||||||
|
|
||||||
|
# # Bold
|
||||||
|
echo ' Bold Colors' $(char newline) $(char newline) | str collect
|
||||||
|
|
||||||
|
# | Value | Color |
|
||||||
|
# | -------- | -------- |
|
||||||
|
# | \e[1;30m | Black |
|
||||||
|
# | \e[1;31m | Red |
|
||||||
|
# | \e[1;32m | Green |
|
||||||
|
# | \e[1;33m | Yellow |
|
||||||
|
# | \e[1;34m | Blue |
|
||||||
|
# | \e[1;35m | Purple |
|
||||||
|
# | \e[1;36m | Cyan |
|
||||||
|
# | \e[1;37m | White |
|
||||||
|
# | \e[1m | No Color |
|
||||||
|
echo '| Value | Color |' $(char newline) | str collect
|
||||||
|
echo '| ----- | ----- |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_black) $(bold_on) ' 1;30m ' $(relet) '| ' Black ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_red) $(bold_on) ' 1;31m ' $(relet) '| ' Red ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_green) $(bold_on) ' 1;32m ' $(relet) '| ' Green ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_yellow) $(bold_on) ' 1;33m ' $(relet) '| ' Yellow ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_blue) $(bold_on) ' 1;34m ' $(relet) '| ' Blue ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_purple) $(bold_on) ' 1;35m ' $(relet) '| ' Purple ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_cyan) $(bold_on) ' 1;36m ' $(relet) '| ' Cyan ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_white) $(bold_on) ' 1;37m ' $(relet) '| ' White ' |' $(char newline) | str collect
|
||||||
|
echo $(char newline)
|
||||||
|
|
||||||
|
# # Underline
|
||||||
|
echo ' Underline Colors' $(char newline) $(char newline) | str collect
|
||||||
|
|
||||||
|
# | Value | Color |
|
||||||
|
# | -------- | -------- |
|
||||||
|
# | \e[4;30m | Black |
|
||||||
|
# | \e[4;31m | Red |
|
||||||
|
# | \e[4;32m | Green |
|
||||||
|
# | \e[4;33m | Yellow |
|
||||||
|
# | \e[4;34m | Blue |
|
||||||
|
# | \e[4;35m | Purple |
|
||||||
|
# | \e[4;36m | Cyan |
|
||||||
|
# | \e[4;37m | White |
|
||||||
|
# | \e[4m | No Color |
|
||||||
|
echo '| Value | Color |' $(char newline) | str collect
|
||||||
|
echo '| ----- | ----- |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_black) $(underline_on) ' 4;30m ' $(relet) '| ' Black ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_red) $(underline_on) ' 4;31m ' $(relet) '| ' Red ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_green) $(underline_on) ' 4;32m ' $(relet) '| ' Green ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_yellow) $(underline_on) ' 4;33m ' $(relet) '| ' Yellow ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_blue) $(underline_on) ' 4;34m ' $(relet) '| ' Blue ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_purple) $(underline_on) ' 4;35m ' $(relet) '| ' Purple ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_cyan) $(underline_on) ' 4;36m ' $(relet) '| ' Cyan ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_white) $(underline_on) ' 4;37m ' $(relet) '| ' White ' |' $(char newline) | str collect
|
||||||
|
echo $(char newline)
|
||||||
|
|
||||||
|
# # Background
|
||||||
|
echo ' Background Colors' $(char newline) $(char newline) | str collect
|
||||||
|
|
||||||
|
# | Value | Color |
|
||||||
|
# | ------ | ------ |
|
||||||
|
# | \e[40m | Black |
|
||||||
|
# | \e[41m | Red |
|
||||||
|
# | \e[42m | Green |
|
||||||
|
# | \e[43m | Yellow |
|
||||||
|
# | \e[44m | Blue |
|
||||||
|
# | \e[45m | Purple |
|
||||||
|
# | \e[46m | Cyan |
|
||||||
|
# | \e[47m | White |
|
||||||
|
echo '| Value | Color |' $(char newline) | str collect
|
||||||
|
echo '| ----- | ----- |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_black) ' 0;40m ' $(relet) '| ' Black ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_red) ' 0;41m ' $(relet) '| ' Red ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_green) ' 0;42m ' $(relet) '| ' Green ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_yellow) ' 0;43m ' $(relet) '| ' Yellow ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_blue) ' 0;44m ' $(relet) '| ' Blue ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_purple) ' 0;45m ' $(relet) '| ' Purple ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_cyan) ' 0;46m ' $(relet) '| ' Cyan ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_white) ' 0;47m ' $(relet) '| ' White ' |' $(char newline) | str collect
|
||||||
|
echo $(char newline)
|
||||||
|
|
||||||
|
# # Expand Background Horizontally
|
||||||
|
|
||||||
|
# | Value | Color |
|
||||||
|
# | ----- | -------- |
|
||||||
|
# | \e[K | No Color |
|
||||||
|
|
||||||
|
# # High Intensty
|
||||||
|
echo ' High Intensity' $(char newline) $(char newline) | str collect
|
||||||
|
|
||||||
|
# | Value | Color |
|
||||||
|
# | -------- | ------ |
|
||||||
|
# | \e[0;90m | Black |
|
||||||
|
# | \e[0;91m | Red |
|
||||||
|
# | \e[0;92m | Green |
|
||||||
|
# | \e[0;93m | Yellow |
|
||||||
|
# | \e[0;94m | Blue |
|
||||||
|
# | \e[0;95m | Purple |
|
||||||
|
# | \e[0;96m | Cyan |
|
||||||
|
# | \e[0;97m | White |
|
||||||
|
echo '| Value | Color |' $(char newline) | str collect
|
||||||
|
echo '| ----- | ----- |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_black) ' 0;90m ' $(relet) '| ' Black ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_red) ' 0;91m ' $(relet) '| ' Red ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_green) ' 0;92m ' $(relet) '| ' Green ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_yellow) ' 0;93m ' $(relet) '| ' Yellow ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_blue) ' 0;94m ' $(relet) '| ' Blue ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_purple) ' 0;95m ' $(relet) '| ' Purple ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_cyan) ' 0;96m ' $(relet) '| ' Cyan ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_white) ' 0;97m ' $(relet) '| ' White ' |' $(char newline) | str collect
|
||||||
|
echo $(char newline)
|
||||||
|
|
||||||
|
# # Bold High Intensty
|
||||||
|
echo ' Bold High Intensity' $(char newline) $(char newline) | str collect
|
||||||
|
|
||||||
|
# | Value | Color |
|
||||||
|
# | -------- | ------ |
|
||||||
|
# | \e[1;90m | Black |
|
||||||
|
# | \e[1;91m | Red |
|
||||||
|
# | \e[1;92m | Green |
|
||||||
|
# | \e[1;93m | Yellow |
|
||||||
|
# | \e[1;94m | Blue |
|
||||||
|
# | \e[1;95m | Purple |
|
||||||
|
# | \e[1;96m | Cyan |
|
||||||
|
# | \e[1;97m | White |
|
||||||
|
echo '| Value | Color |' $(char newline) | str collect
|
||||||
|
echo '| ----- | ----- |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_black) $(bold_on) ' 1;90m ' $(relet) '| ' Black ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_red) $(bold_on) ' 1;91m ' $(relet) '| ' Red ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_green) $(bold_on) ' 1;92m ' $(relet) '| ' Green ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_yellow) $(bold_on) ' 1;93m ' $(relet) '| ' Yellow ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_blue) $(bold_on) ' 1;94m ' $(relet) '| ' Blue ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_purple) $(bold_on) ' 1;95m ' $(relet) '| ' Purple ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_cyan) $(bold_on) ' 1;96m ' $(relet) '| ' Cyan ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(fg_light_white) $(bold_on) ' 1;97m ' $(relet) '| ' White ' |' $(char newline) | str collect
|
||||||
|
echo $(char newline)
|
||||||
|
|
||||||
|
# # High Intensty backgrounds
|
||||||
|
echo ' High Intensity backgrounds' $(char newline) $(char newline) | str collect
|
||||||
|
|
||||||
|
# | Value | Color |
|
||||||
|
# | --------- | ------ |
|
||||||
|
# | \e[0;100m | Black |
|
||||||
|
# | \e[0;101m | Red |
|
||||||
|
# | \e[0;102m | Green |
|
||||||
|
# | \e[0;103m | Yellow |
|
||||||
|
# | \e[0;104m | Blue |
|
||||||
|
# | \e[0;105m | Purple |
|
||||||
|
# | \e[0;106m | Cyan |
|
||||||
|
# | \e[0;107m | White |
|
||||||
|
echo '| Value | Color |' $(char newline) | str collect
|
||||||
|
echo '| ----- | ----- |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_light_black) ' 0;100m ' $(relet) '| ' Black ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_light_red) ' 0;101m ' $(relet) '| ' Red ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_light_green) ' 0;102m ' $(relet) '| ' Green ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_light_yellow) ' 0;103m ' $(relet) '| ' Yellow ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_light_blue) ' 0;104m ' $(relet) '| ' Blue ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_light_purple) ' 0;105m ' $(relet) '| ' Purple ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_light_cyan) ' 0;106m ' $(relet) '| ' Cyan ' |' $(char newline) | str collect
|
||||||
|
echo '|' $(bg_light_white) ' 0;107m ' $(relet) '| ' White ' |' $(char newline) | str collect
|
||||||
|
echo $(char newline)
|
||||||
|
|
||||||
|
# # Reset
|
||||||
|
|
||||||
|
# | Value | Color |
|
||||||
|
# | ----- | ------ |
|
||||||
|
# | \e[0m | Reset |
|
24
table.sh
Executable file
24
table.sh
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# generates an 8 bit color table (256 colors) for reference,
|
||||||
|
# using the ANSI CSI+SGR \033[48;5;${val}m for background and
|
||||||
|
# \033[38;5;${val}m for text (see "ANSI Code" on Wikipedia)
|
||||||
|
#
|
||||||
|
echo -en "\n + "
|
||||||
|
for i in {0..35}; do
|
||||||
|
printf "%2b " $i
|
||||||
|
done
|
||||||
|
printf "\n\n %3b " 0
|
||||||
|
for i in {0..15}; do
|
||||||
|
echo -en "\033[48;5;${i}m \033[m "
|
||||||
|
done
|
||||||
|
#for i in 16 52 88 124 160 196 232; do
|
||||||
|
for i in {0..6}; do
|
||||||
|
let "i = i*36 +16"
|
||||||
|
printf "\n\n %3b " $i
|
||||||
|
for j in {0..35}; do
|
||||||
|
let "val = i+j"
|
||||||
|
echo -en "\033[48;5;${val}m \033[m "
|
||||||
|
done
|
||||||
|
done
|
||||||
|
echo -e "\n"
|
Loading…
Add table
Add a link
Reference in a new issue