mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
updated for 0.32.0 release
This commit is contained in:
parent
8811fc2042
commit
160fd54729
37 changed files with 485 additions and 482 deletions
|
@ -1,15 +1,15 @@
|
|||
let term_cols = $(= $(term size -w) - 1)
|
||||
let term_cols = ((term size -w) - 1)
|
||||
|
||||
echo 0..$term_cols |
|
||||
each {
|
||||
let r = $(= 255 - ($it * 255 / $term_cols) | math round)
|
||||
let g = $(= $it * 510 / $term_cols | math round)
|
||||
let b = $(= $it * 255 / $term_cols | math round)
|
||||
let r = (255 - ($it * 255 / $term_cols) | math round)
|
||||
let g = ($it * 510 / $term_cols | math round)
|
||||
let b = ($it * 255 / $term_cols | math round)
|
||||
if $g > 255 {
|
||||
let g = $(= 510 - $g)
|
||||
echo $(build-colorstr $r $g $b) | autoview
|
||||
let g = (510 - $g)
|
||||
echo (build-colorstr $r $g $b) | autoview
|
||||
} {
|
||||
echo $(build-colorstr $r $g $b) | autoview
|
||||
echo (build-colorstr $r $g $b) | autoview
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,22 +18,22 @@ def build-colorstr [
|
|||
g:int # Green
|
||||
b:int # Blue
|
||||
] {
|
||||
# log $(build-string "R=" $r " G=" $g " B=" $b)
|
||||
let bg = $(build-string $(ansi rgb_bg) $r ';' $g ';' $b 'm')
|
||||
let fg = $(build-string $(ansi rgb_fg) $(= 255 - $r) ';' $(= 255 - $g) ';' $(= 255 - $b) 'm')
|
||||
let idx = $(= $it mod 2)
|
||||
let slash_str = $(if $idx == 0 {
|
||||
build-string "/" $(ansi reset)
|
||||
# log (build-string "R=" $r " G=" $g " B=" $b)
|
||||
let bg = (build-string (ansi rgb_bg) $r ';' $g ';' $b 'm')
|
||||
let fg = (build-string (ansi rgb_fg) (255 - $r) ';' (255 - $g) ';' (255 - $b) 'm')
|
||||
let idx = ($it mod 2)
|
||||
let slash_str = (if $idx == 0 {
|
||||
build-string "/" (ansi reset)
|
||||
} {
|
||||
build-string "\" $(ansi reset)
|
||||
build-string "\" (ansi reset)
|
||||
})
|
||||
build-string $bg $fg $slash_str
|
||||
# log $(build-string $bg $fg $slash_str | debug)
|
||||
# log (build-string $bg $fg $slash_str | debug)
|
||||
}
|
||||
|
||||
# This is a first attempt and some type of logging
|
||||
def log [message:any] {
|
||||
let now = $(date now | date format '%Y%m%d_%H%M%S.%f')
|
||||
let mess = $(build-string $now '|DBG|' $message $(char newline))
|
||||
let now = (date now | date format '%Y%m%d_%H%M%S.%f')
|
||||
let mess = (build-string $now '|DBG|' $message (char newline))
|
||||
echo $mess | autoview
|
||||
}
|
|
@ -1,24 +1,24 @@
|
|||
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 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
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,42 +27,42 @@ def make_header [hi] {
|
|||
# mk_header is more convoluted but less repetitive
|
||||
|
||||
def mk_header [color_range:range] {
|
||||
let min_rng = $(echo $color_range | math min)
|
||||
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')])
|
||||
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 ' ')
|
||||
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 ' ')
|
||||
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 ' ')
|
||||
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 ' ')
|
||||
let header = (echo $ansi_color | str lpad -l $lo_regular_pad -c ' ')
|
||||
echo $header
|
||||
}
|
||||
}
|
||||
} | str collect
|
||||
echo $(char newline)
|
||||
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)
|
||||
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)
|
||||
} | append (char newline) | str collect)
|
||||
echo [$row_header $row_data] | str collect
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ def color_table [] {
|
|||
create_color_tables 30..37 40..47
|
||||
|
||||
# put a line between tables
|
||||
echo $(char newline)
|
||||
echo (char newline)
|
||||
|
||||
#make_header $true
|
||||
mk_header 100..107
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
|
||||
echo 0..8 | each {
|
||||
let x = $it
|
||||
let row = $(echo 30..37 | each {
|
||||
let row = (echo 30..37 | each {
|
||||
let i = $it
|
||||
let row = $(echo 40..47 | each {
|
||||
let row = (echo 40..47 | each {
|
||||
let a = $it
|
||||
let color = $(build-string $x ';' $i ';' $a 'm')
|
||||
echo [$(ansi -e $color) $color $(ansi reset) ' ']
|
||||
let color = (build-string $x ';' $i ';' $a 'm')
|
||||
echo [(ansi -e $color) $color (ansi reset) ' ']
|
||||
} | str collect)
|
||||
echo [$row $(char newline)] | str collect
|
||||
echo [$row (char newline)] | str collect
|
||||
} | str collect)
|
||||
echo [$row $(char newline)] | str collect
|
||||
echo [$row (char newline)] | str collect
|
||||
} | str collect
|
|
@ -4,37 +4,36 @@ 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))
|
||||
let row_data = (seq 0 $width | each {
|
||||
let fgcolor = (iter_inc 2 2 $it)
|
||||
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) 'Nu' (ansi -e '0m')] | str collect
|
||||
} {
|
||||
echo [$(ansi -e '48;2;0;0;') $(build-string $fgcolor m) ' ' $(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
|
||||
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
|
||||
# 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 │
|
||||
# ╰────┴────────────────────┴──────────────────────────────────────────────────────────────────────────────────────╯
|
||||
# ╭────┬────────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
# │ # │ key │ value │
|
||||
# ├────┼────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
# │ 0 │ version │ 0.31.1 │
|
||||
# │ 1 │ branch │ main │
|
||||
# │ 2 │ short_commit │ 3aa00b78 │
|
||||
# │ 3 │ commit_hash │ 3aa00b78f95b308a6d76eef086e018cd0e0252d0 │
|
||||
# │ 4 │ commit_date │ 2021-05-12 03:53:34 │
|
||||
# │ 5 │ build_os │ windows-x86_64 │
|
||||
# │ 6 │ rust_version │ rustc 1.52.1 (9bc8c42bb 2021-05-09) │
|
||||
# │ 7 │ rust_channel │ stable (default) │
|
||||
# │ 8 │ cargo_version │ cargo 1.52.0 (69767412a 2021-04-21) │
|
||||
# │ 9 │ pkg_version │ 0.31.1 │
|
||||
# │ 10 │ build_time │ 2021-05-12 07:37:45 │
|
||||
# │ 11 │ build_rust_channel │ release │
|
||||
# │ 12 │ features │ clipboard-cli, ctrlc, default, directories, dirs, ptree, rustyline, term, trash, uuid, which, zip │
|
||||
# ╰────┴────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────╯
|
|
@ -2,13 +2,13 @@ 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'))
|
||||
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) (char newline)]
|
||||
} {
|
||||
echo [$color $padded_number ' ' $(ansi -e $relet_color)]
|
||||
echo [$color $padded_number ' ' (ansi -e $relet_color)]
|
||||
}
|
||||
} | str collect
|
||||
}
|
||||
|
@ -16,4 +16,4 @@ def show_index_colors [] {
|
|||
show_index_colors
|
||||
|
||||
#one-liner
|
||||
#echo 0..255 | each {echo [$(ansi -e '38;5;') $(build-string $it) 'm' $(build-string $it) ' ']} | str collect
|
||||
#echo 0..255 | each {echo [(ansi -e '38;5;') (build-string $it) 'm' (build-string $it) ' ']} | str collect
|
|
@ -1,11 +1,11 @@
|
|||
def show_index_colors [] {
|
||||
let prefix = "38;5;"
|
||||
echo 1..256 | each {
|
||||
let cr = $(echo $(build-string $it % 16) | math eval)
|
||||
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') ' ' (char newline)]
|
||||
} {
|
||||
echo [$(ansi -e $prefix) $(build-string $it) 'm' $(build-string $it | str lpad -l 3 -c '0') ' ']
|
||||
echo [(ansi -e $prefix) (build-string $it) 'm' (build-string $it | str lpad -l 3 -c '0') ' ']
|
||||
}
|
||||
} | str collect
|
||||
}
|
||||
|
@ -13,4 +13,4 @@ def show_index_colors [] {
|
|||
show_index_colors
|
||||
|
||||
#one-liner
|
||||
#echo 0..255 | each {echo [$(ansi -e '38;5;') $(build-string $it) 'm' $(build-string $it) ' ']} | str collect
|
||||
#echo 0..255 | each {echo [(ansi -e '38;5;') (build-string $it) 'm' (build-string $it) ' ']} | str collect
|
|
@ -4,11 +4,11 @@
|
|||
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'))
|
||||
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 ' ' (char newline)]
|
||||
} {
|
||||
echo [$color $padded_number ' ']
|
||||
}
|
||||
|
@ -21,4 +21,4 @@ show_index_colors
|
|||
# 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
|
||||
#echo 1..256 | each {echo [(ansi -e '38;5;') (build-string $it) 'm' (build-string $it) ' ']} | str collect
|
|
@ -15,25 +15,25 @@ def 'to str' [] {
|
|||
# Foreground Colors
|
||||
echo 0..16 | each {
|
||||
let i = $it
|
||||
let row = $(echo 0..16 | each {
|
||||
let row = (echo 0..16 | each {
|
||||
let j = $it
|
||||
let code = $(= $i * 16 + $j)
|
||||
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
|
||||
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
|
||||
echo [$row (char newline)] | str collect
|
||||
} | str collect
|
||||
|
||||
# Background Colors
|
||||
echo 0..16 | each {
|
||||
let i = $it
|
||||
let row = $(echo 0..16 | each {
|
||||
let row = (echo 0..16 | each {
|
||||
let j = $it
|
||||
let code = $(= $i * 16 + $j)
|
||||
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
|
||||
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
|
||||
echo [$row (char newline)] | str collect
|
||||
} | str collect
|
||||
|
|
|
@ -2,32 +2,32 @@
|
|||
# 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)
|
||||
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)
|
||||
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 ' ']
|
||||
let row_data = (seq 0 15 | each {
|
||||
build-string $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') ' ']
|
||||
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
|
||||
build-string $row_header ' ' $row_data $nl $nl
|
||||
} | str collect
|
||||
|
||||
|
|
|
@ -14,12 +14,12 @@ echo 40..47 100..107 49 | each {
|
|||
# 7 Reverse Video
|
||||
# 8 Conceal (not widely supported)
|
||||
# 9 Strike-through
|
||||
let row = $(echo 0..9 | each {
|
||||
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
|
||||
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
|
||||
echo [$row (char newline)] | str collect | autoview
|
||||
} | str collect
|
||||
} | str collect
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
source ../stdlib_candidate/nu_style.nu
|
||||
|
||||
# # Regular Colors
|
||||
echo ' Regular Colors' $(char newline) $(char newline) | str collect
|
||||
echo ' Regular Colors' (char newline) (char newline) | str collect
|
||||
# | Value | Color |
|
||||
# | -------- | ------ |
|
||||
# | \e[0;30m | Black |
|
||||
|
@ -12,20 +12,20 @@ echo ' Regular Colors' $(char newline) $(char newline) | str collect
|
|||
# | \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)
|
||||
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
|
||||
echo ' Bold Colors' (char newline) (char newline) | str collect
|
||||
|
||||
# | Value | Color |
|
||||
# | -------- | -------- |
|
||||
|
@ -38,20 +38,20 @@ echo ' Bold Colors' $(char newline) $(char newline) | str collect
|
|||
# | \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)
|
||||
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
|
||||
echo ' Underline Colors' (char newline) (char newline) | str collect
|
||||
|
||||
# | Value | Color |
|
||||
# | -------- | -------- |
|
||||
|
@ -64,20 +64,20 @@ echo ' Underline Colors' $(char newline) $(char newline) | str collect
|
|||
# | \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)
|
||||
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
|
||||
echo ' Background Colors' (char newline) (char newline) | str collect
|
||||
|
||||
# | Value | Color |
|
||||
# | ------ | ------ |
|
||||
|
@ -89,17 +89,17 @@ echo ' Background Colors' $(char newline) $(char newline) | str collect
|
|||
# | \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)
|
||||
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
|
||||
|
||||
|
@ -108,7 +108,7 @@ echo $(char newline)
|
|||
# | \e[K | No Color |
|
||||
|
||||
# # High Intensty
|
||||
echo ' High Intensity' $(char newline) $(char newline) | str collect
|
||||
echo ' High Intensity' (char newline) (char newline) | str collect
|
||||
|
||||
# | Value | Color |
|
||||
# | -------- | ------ |
|
||||
|
@ -120,20 +120,20 @@ echo ' High Intensity' $(char newline) $(char newline) | str collect
|
|||
# | \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)
|
||||
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
|
||||
echo ' Bold High Intensity' (char newline) (char newline) | str collect
|
||||
|
||||
# | Value | Color |
|
||||
# | -------- | ------ |
|
||||
|
@ -145,20 +145,20 @@ echo ' Bold High Intensity' $(char newline) $(char newline) | str collect
|
|||
# | \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)
|
||||
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
|
||||
echo ' High Intensity backgrounds' (char newline) (char newline) | str collect
|
||||
|
||||
# | Value | Color |
|
||||
# | --------- | ------ |
|
||||
|
@ -170,17 +170,17 @@ echo ' High Intensity backgrounds' $(char newline) $(char newline) | str collect
|
|||
# | \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)
|
||||
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
|
||||
|
||||
|
|
|
@ -5,10 +5,10 @@ def duplicates [
|
|||
] {
|
||||
group-by $column |
|
||||
pivot |
|
||||
insert count { = $it.Column1 | flatten | length } |
|
||||
insert count { $it.Column1 | flatten | length } |
|
||||
where count > 1 |
|
||||
reject Column0 |
|
||||
if $(= $count | empty?) { reject count } { each {= $it } } |
|
||||
if ($count | empty?) { reject count } { each { $it } } |
|
||||
flatten |
|
||||
flatten
|
||||
}
|
||||
|
|
16
fehbg.nu
16
fehbg.nu
|
@ -20,13 +20,13 @@
|
|||
# xinitrc.
|
||||
#
|
||||
# Dependencies;
|
||||
# * nu version >0.25.1 (0.25.1 doesn't work due to coercion error bug)
|
||||
# * nu version >=0.31.1 (requires new syntax introduced in 0.31.1 and 0.32.0)
|
||||
# * feh
|
||||
# * imagemagick
|
||||
|
||||
# Path definitions
|
||||
let img_dir = $nu.env.WALLPAPER_DIR
|
||||
let tmp_image = $(build-string $nu.env.TMP_DIR "/wallpaper.jpg")
|
||||
let tmp_image = (echo [ $nu.env.TMP_DIR "wallpaper.jpg" ] | path join)
|
||||
|
||||
# Monitor resolution
|
||||
let resolution_y = 1440
|
||||
|
@ -40,7 +40,7 @@ def select_random [] { shuffle | first }
|
|||
|
||||
# List all images in a directory and all its subdirectories
|
||||
def list_images [dir] {
|
||||
ls $(build-string $dir /**/*) | where type == File | where name =~ jpg || name =~ jpeg || name =~ tif || name =~ tiff
|
||||
ls (build-string $dir /**/*) | where type == File | where name =~ jpg || name =~ jpeg || name =~ tif || name =~ tiff
|
||||
}
|
||||
|
||||
# Set the caption text (just filename for now)
|
||||
|
@ -50,15 +50,15 @@ def caption [img_f] {
|
|||
|
||||
# Build the argument for the '-draw' command of the 'convert' utility
|
||||
def draw_str [img_f] {
|
||||
build-string 'text ' $pos_x ',' $pos_y ' "' $(caption $img_f) '" '
|
||||
build-string 'text ' $pos_x ',' $pos_y ' "' (caption $img_f) '" '
|
||||
}
|
||||
|
||||
# Select random image
|
||||
let img_name = $(list_images $img_dir | select_random | get name)
|
||||
let img_name = (list_images $img_dir | select_random | get name)
|
||||
|
||||
# Resize the image to the monitor height, draw the caption and save it
|
||||
let res_str = $(build-string 'x' $resolution_y)
|
||||
convert -resize $res_str -pointsize 15 -fill "rgb(255,200,150)" -draw $(draw_str $img_name) $img_name $tmp_image
|
||||
let res_str = (build-string 'x' $resolution_y)
|
||||
convert -resize $res_str -pointsize 15 -fill "rgb(255,200,150)" -draw (draw_str $img_name) $img_name $tmp_image
|
||||
|
||||
# Set the created image as a background
|
||||
feh --no-fehbg --bg-max $tmp_image
|
||||
feh --no-fehbg --bg-max $tmp_image
|
|
@ -18,78 +18,78 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
|
||||
# generate typescript from nushell commands
|
||||
def gen-ts-cmds [] {
|
||||
# let cmds = $(help commands | do -i { each { where $it.subcommands == $nothing }} | where description != '' | select name description)
|
||||
let cmds = $(help commands | where description != '' | select name description)
|
||||
let updated_cmds = $(echo $cmds | insert camel { build-string $it.name 'Completion' | str camel-case } )
|
||||
# let cmds = (help commands | do -i { each { where $it.subcommands == $nothing }} | where description != '' | select name description)
|
||||
let cmds = (help commands | where description != '' | select name description)
|
||||
let updated_cmds = (echo $cmds | insert camel { build-string $it.name 'Completion' | str camel-case } )
|
||||
|
||||
let ts = $(echo $updated_cmds |
|
||||
let ts = (echo $updated_cmds |
|
||||
each {
|
||||
let line1 = $(build-string " const " $it.camel " = new vscode.CompletionItem('" $it.name "');" $(char newline))
|
||||
let line2 = $(build-string " " $it.camel ".commitCharacters = [' '];" $(char newline) $(char newline))
|
||||
let line1 = (build-string " const " $it.camel " = new vscode.CompletionItem('" $it.name "');" (char newline))
|
||||
let line2 = (build-string " " $it.camel ".commitCharacters = [' '];" (char newline) (char newline))
|
||||
build-string $line1 $line2
|
||||
} | str collect)
|
||||
|
||||
build-string $(echo $ts) $(char nl) " return [ " $(echo $updated_cmds | get camel | str collect ', ') " ];" $(char nl) ' },' $(char nl) ' }' $(char nl) ' );' $(char nl) $(char nl) | str collect
|
||||
build-string (echo $ts) (char nl) " return [ " (echo $updated_cmds | get camel | str collect ', ') " ];" (char nl) ' },' (char nl) ' }' (char nl) ' );' (char nl) (char nl) | str collect
|
||||
}
|
||||
|
||||
# generate typescript from nushell subcommands
|
||||
def gen-ts-subs [] {
|
||||
let cmds = $(help commands | get subcommands | insert base { get name | split column ' ' base sub} | flatten)
|
||||
let updated_cmds = $(echo $cmds | insert camelProvider {build-string $it.base 'SubCommandsProvider' | str camel-case } | insert method {build-string $it.name | str camel-case})
|
||||
let subs_count = $(help commands | get subcommands | insert base { get name | split column ' ' base sub} | flatten | group-by base | pivot cmd cmd_count | update cmd_count { get cmd_count | length })
|
||||
let subs_collection = $(help commands | get subcommands | insert base { get name | split column ' ' base sub} | flatten | group-by base | pivot cmd sub_cmds)
|
||||
let cmds = (help commands | get subcommands | insert base { get name | split column ' ' base sub} | flatten)
|
||||
let updated_cmds = (echo $cmds | insert camelProvider {build-string $it.base 'SubCommandsProvider' | str camel-case } | insert method {build-string $it.name | str camel-case})
|
||||
let subs_count = (help commands | get subcommands | insert base { get name | split column ' ' base sub} | flatten | group-by base | pivot cmd cmd_count | update cmd_count { get cmd_count | length })
|
||||
let subs_collection = (help commands | get subcommands | insert base { get name | split column ' ' base sub} | flatten | group-by base | pivot cmd sub_cmds)
|
||||
|
||||
let ts = $(echo $subs_collection |
|
||||
let ts = (echo $subs_collection |
|
||||
each {
|
||||
let preamble = $(get sub_cmds | each --numbered {
|
||||
let preamble = (get sub_cmds | each --numbered {
|
||||
# echo `index={{$it.index}} base={{$it.item.base}} sub={{$it.item.sub}}`
|
||||
let method = $(build-string $it.item.name | str camel-case)
|
||||
let camel = $(build-string $it.item.base 'SubCommandsProvider' | str camel-case)
|
||||
let method = (build-string $it.item.name | str camel-case)
|
||||
let camel = (build-string $it.item.base 'SubCommandsProvider' | str camel-case)
|
||||
if $it.index == 0 {
|
||||
let line01 = $(build-string " const " $camel " = vscode.languages.registerCompletionItemProvider(" $(char newline))
|
||||
let line02 = $(build-string " 'nushell'," $(char nl))
|
||||
let line03 = $(build-string " {" $(char nl))
|
||||
let line04 = $(build-string " provideCompletionItems(document: vscode.TextDocument, position: vscode.Position) {" $(char nl) $(char nl))
|
||||
let line05 = $(build-string " const linePrefix = document.lineAt(position).text.substr(0, position.character);" $(char nl))
|
||||
let line06 = $(build-string " if (linePrefix.endsWith('" $it.item.base " ')) {" $(char nl) $(char nl))
|
||||
let line07 = $(build-string " const " $method " = new vscode.CompletionItem('" $it.item.sub "', vscode.CompletionItemKind.Method);" $(char nl))
|
||||
let line08 = $(build-string ' ' $method '.detail = "' $it.item.description '";' $(char nl) $(char nl))
|
||||
let line01 = (build-string " const " $camel " = vscode.languages.registerCompletionItemProvider(" (char newline))
|
||||
let line02 = (build-string " 'nushell'," (char nl))
|
||||
let line03 = (build-string " {" (char nl))
|
||||
let line04 = (build-string " provideCompletionItems(document: vscode.TextDocument, position: vscode.Position) {" (char nl) (char nl))
|
||||
let line05 = (build-string " const linePrefix = document.lineAt(position).text.substr(0, position.character);" (char nl))
|
||||
let line06 = (build-string " if (linePrefix.endsWith('" $it.item.base " ')) {" (char nl) (char nl))
|
||||
let line07 = (build-string " const " $method " = new vscode.CompletionItem('" $it.item.sub "', vscode.CompletionItemKind.Method);" (char nl))
|
||||
let line08 = (build-string ' ' $method '.detail = "' $it.item.description '";' (char nl) (char nl))
|
||||
build-string $line01 $line02 $line03 $line04 $line05 $line06 $line07 $line08
|
||||
} {
|
||||
let line07 = $(build-string " const " $method " = new vscode.CompletionItem('" $it.item.sub "', vscode.CompletionItemKind.Method);" $(char nl))
|
||||
let line08 = $(build-string ' ' $method '.detail = "' $it.item.description '";' $(char nl) $(char nl))
|
||||
let line07 = (build-string " const " $method " = new vscode.CompletionItem('" $it.item.sub "', vscode.CompletionItemKind.Method);" (char nl))
|
||||
let line08 = (build-string ' ' $method '.detail = "' $it.item.description '";' (char nl) (char nl))
|
||||
build-string $line07 $line08
|
||||
}
|
||||
} | str collect)
|
||||
|
||||
let methods = $(echo $it.sub_cmds.name | str camel-case | str collect ', ')
|
||||
let methods = (echo $it.sub_cmds.name | str camel-case | str collect ', ')
|
||||
|
||||
let line09 = $(build-string " return [" $(char nl))
|
||||
let line10 = $(build-string " " $methods $(char nl))
|
||||
let line11 = $(build-string " ];" $(char nl))
|
||||
let line12 = $(build-string " } else {" $(char nl))
|
||||
let line13 = $(build-string " return undefined;" $(char nl))
|
||||
let line14 = $(build-string " }" $(char nl))
|
||||
let line15 = $(build-string " }" $(char nl))
|
||||
let line16 = $(build-string " }," $(char nl))
|
||||
let line17 = $(build-string " ' '" $(char nl))
|
||||
let line18 = $(build-string " );" $(char nl) $(char nl))
|
||||
let line09 = (build-string " return [" (char nl))
|
||||
let line10 = (build-string " " $methods (char nl))
|
||||
let line11 = (build-string " ];" (char nl))
|
||||
let line12 = (build-string " } else {" (char nl))
|
||||
let line13 = (build-string " return undefined;" (char nl))
|
||||
let line14 = (build-string " }" (char nl))
|
||||
let line15 = (build-string " }" (char nl))
|
||||
let line16 = (build-string " }," (char nl))
|
||||
let line17 = (build-string " ' '" (char nl))
|
||||
let line18 = (build-string " );" (char nl) (char nl))
|
||||
|
||||
build-string $preamble $line09 $line10 $line11 $line12 $line13 $line14 $line15 $line16 $line17 $line18
|
||||
} | str collect)
|
||||
|
||||
echo $subs_collection |
|
||||
let post01 = $(build-string " context.subscriptions.push(" $(char nl))
|
||||
let post02 = $(build-string " " $(echo $updated_cmds | get camelProvider | uniq | str collect ', ') $(char nl))
|
||||
let post03 = $(build-string " );" $(char nl) "}" $(char nl))
|
||||
let post01 = (build-string " context.subscriptions.push(" (char nl))
|
||||
let post02 = (build-string " " (echo $updated_cmds | get camelProvider | uniq | str collect ', ') (char nl))
|
||||
let post03 = (build-string " );" (char nl) "}" (char nl))
|
||||
|
||||
build-string $ts $post01 $post02 $post03
|
||||
}
|
||||
|
||||
# def log [message:any] {
|
||||
# let now = $(date now | date format '%Y%m%d_%H%M%S.%f')
|
||||
# let mess = $(build-string $now '|DBG|' $message $(char newline))
|
||||
# let now = (date now | date format '%Y%m%d_%H%M%S.%f')
|
||||
# let mess = (build-string $now '|DBG|' $message (char newline))
|
||||
# echo $mess | autoview
|
||||
# }
|
||||
|
||||
build-string $(gen-ts-cmds-begin) $(gen-ts-cmds) $(gen-ts-subs) | save extension.ts
|
||||
build-string (gen-ts-cmds-begin) (gen-ts-cmds) (gen-ts-subs) | save extension.ts
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
def ls-incorrect-dirs [] {
|
||||
ls | where type == 'Dir' && name != 'scripts'| match -v name '(\d+\.){2,}\d$'
|
||||
}
|
||||
let incorrect_count = $(ls-incorrect-dirs | length);
|
||||
let incorrect_count = (ls-incorrect-dirs | length);
|
||||
if $incorrect_count > 0 {
|
||||
echo `The following directories are named incorrectly: {{$(char newline)}}`
|
||||
echo `The following directories are named incorrectly: {{(char newline)}}`
|
||||
ls-incorrect-dirs
|
||||
exit 1
|
||||
} {
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
def ls-less [
|
||||
--dir(-d):any # The directory you want to list
|
||||
] {
|
||||
let is_empty = $(= $dir | empty?)
|
||||
let is_empty = ($dir | empty?)
|
||||
if $is_empty {
|
||||
nu -c 'ls' | less -r
|
||||
} {
|
||||
let command = $(build-string 'ls ' $dir)
|
||||
let command = (build-string 'ls ' $dir)
|
||||
nu -c $command | less -r
|
||||
}
|
||||
}
|
|
@ -26,47 +26,47 @@ alias fg_light_white = ansi -e '97m'
|
|||
def ls-wide2 [
|
||||
--columns(-c):int # The number of columns in your output
|
||||
] {
|
||||
let is_empty = $(= $columns | empty?)
|
||||
let ls_data = $(ls)
|
||||
let is_empty = ($columns | empty?)
|
||||
let ls_data = (ls)
|
||||
let ansi_size = 9 # \x1b[36m + string + \x1b[0m, ~9 characters are added to each string for coloring
|
||||
let max_fname_size = $(= $(echo $ls_data | get name | str from | str length | math max) + $ansi_size)
|
||||
let max_fsize_size = $(echo $ls_data | get size | str from | str length | math max)
|
||||
# log $(build-string 'max_fname_size=' $max_fname_size ' max_fsize_size=' $max_fsize_size)
|
||||
let max_fname_size = ((echo $ls_data | get name | str from | str length | math max) + $ansi_size)
|
||||
let max_fsize_size = (echo $ls_data | get size | str from | str length | math max)
|
||||
# log (build-string 'max_fname_size=' $max_fname_size ' max_fsize_size=' $max_fsize_size)
|
||||
ls | each -n {
|
||||
let clr_file = $(colorize $it.item.name)
|
||||
# log $(build-string $clr_file ' ' $max_fname_size)
|
||||
let clr_size = $(echo $it.item.size | str from)
|
||||
# log $(build-string $clr_size ' ' $max_fsize_size)
|
||||
build-string $(echo $clr_file | str rpad -c ' ' -l $max_fname_size) ' ' $(echo $clr_size | str lpad -c ' ' -l $max_fsize_size) ' ' | autoview
|
||||
let clr_file = (colorize $it.item.name)
|
||||
# log (build-string $clr_file ' ' $max_fname_size)
|
||||
let clr_size = (echo $it.item.size | str from)
|
||||
# log (build-string $clr_size ' ' $max_fsize_size)
|
||||
build-string (echo $clr_file | str rpad -c ' ' -l $max_fname_size) ' ' (echo $clr_size | str lpad -c ' ' -l $max_fsize_size) ' ' | autoview
|
||||
if $is_empty {
|
||||
if $(= $it.index + 1) mod 3 == 0 {
|
||||
echo $(char newline) | autoview
|
||||
if ($it.index + 1) mod 3 == 0 {
|
||||
echo (char newline) | autoview
|
||||
} {}
|
||||
} {
|
||||
if $(= $it.index + 1) mod $columns == 0 {
|
||||
echo $(char newline) | autoview
|
||||
if ($it.index + 1) mod $columns == 0 {
|
||||
echo (char newline) | autoview
|
||||
} {}
|
||||
}
|
||||
} | str collect
|
||||
}
|
||||
|
||||
def colorize [thing:any] {
|
||||
let thing_as_string = $(echo $thing | str from)
|
||||
let ext = $(echo $thing_as_string | path extension)
|
||||
let is_empty = $(= $ext | empty?)
|
||||
let thing_as_string = (echo $thing | str from)
|
||||
let ext = (echo $thing_as_string | path parse | get extension)
|
||||
let is_empty = ($ext | empty?)
|
||||
|
||||
if $is_empty {
|
||||
# build-string $(ansi -e '36m') $thing $(ansi -e '0m')
|
||||
build-string $(fg_cyan) $thing $(relet)
|
||||
# build-string (ansi -e '36m') $thing (ansi -e '0m')
|
||||
build-string (fg_cyan) $thing (relet)
|
||||
# build-string 'e[36m' $thing 'e[0m'
|
||||
} {
|
||||
if $ext == "nu" {
|
||||
# build-string $(ansi -e '95m') $thing $(ansi -e '0m')
|
||||
build-string $(fg_light_magenta) $thing $(relet)
|
||||
# build-string (ansi -e '95m') $thing (ansi -e '0m')
|
||||
build-string (fg_light_magenta) $thing (relet)
|
||||
# build-string 'e[95m' $thing 'e[0m'
|
||||
} {
|
||||
# build-string $(ansi -e '92m') $thing $(ansi -e '0m')
|
||||
build-string $(fg_light_green) $thing $(relet)
|
||||
# build-string (ansi -e '92m') $thing (ansi -e '0m')
|
||||
build-string (fg_light_green) $thing (relet)
|
||||
# build-string 'e[92m' $thing 'e[0m'
|
||||
}
|
||||
}
|
||||
|
@ -81,17 +81,17 @@ def colorit [] {
|
|||
colorize " file.nu"
|
||||
|
||||
# These all work
|
||||
build-string $(fg_light_green) "abc" $(relet)
|
||||
echo $(fg_cyan) "def" $(relet) | str collect
|
||||
#echo '|' $(fg_light_green) ' 0;92m ' $(relet) '| ' Green ' |' $(char newline) | str collect
|
||||
build-string (fg_light_green) "abc" (relet)
|
||||
echo (fg_cyan) "def" (relet) | str collect
|
||||
#echo '|' (fg_light_green) ' 0;92m ' (relet) '| ' Green ' |' (char newline) | str collect
|
||||
}
|
||||
|
||||
# This is a first attempt and some type of logging
|
||||
def log [
|
||||
message:any # Some log message
|
||||
] {
|
||||
let now = $(date now | date format '%Y%m%d_%H%M%S.%f')
|
||||
let mess = $(build-string $now '|DBG|' $message $(char newline))
|
||||
let now = (date now | date format '%Y%m%d_%H%M%S.%f')
|
||||
let mess = (build-string $now '|DBG|' $message (char newline))
|
||||
echo $mess | autoview
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ def ls-wide [
|
|||
--path(-p):string # The path you want to list
|
||||
--columns(-c):int # The number of columns in your output
|
||||
] {
|
||||
let is_columns_empty = $(= $columns | empty?)
|
||||
let is_path_empty = $(= $path | empty?)
|
||||
let is_columns_empty = ($columns | empty?)
|
||||
let is_path_empty = ($path | empty?)
|
||||
let columns_default = 3
|
||||
|
||||
if $is_path_empty {
|
||||
|
@ -26,18 +26,18 @@ def run_ls [
|
|||
path:string
|
||||
columns:int
|
||||
] {
|
||||
let max_fname_size = $(ls $path | get name | str from | str length | math max)
|
||||
let max_fsize_size = $(ls $path | get size | str from | str length | math max)
|
||||
let max_fname_size = (ls $path | get name | str from | str length | math max)
|
||||
let max_fsize_size = (ls $path | get size | str from | str length | math max)
|
||||
|
||||
ls $path | each -n {
|
||||
build-string $(echo $it.item.name | str rpad -c ' ' -l $max_fname_size) ' ' $(echo $(build-string $it.item.size) | str lpad -c ' ' -l $max_fsize_size) ' '
|
||||
build-string (echo $it.item.name | str rpad -c ' ' -l $max_fname_size) ' ' (echo (build-string $it.item.size) | str lpad -c ' ' -l $max_fsize_size) ' '
|
||||
if $is_columns_empty {
|
||||
if $(= $it.index + 1) mod 3 == 0 {
|
||||
echo $(char newline) | autoview
|
||||
if ($it.index + 1) mod 3 == 0 {
|
||||
echo (char newline) | autoview
|
||||
} {}
|
||||
} {
|
||||
if $(= $it.index + 1) mod $columns == 0 {
|
||||
echo $(char newline) | autoview
|
||||
if ($it.index + 1) mod $columns == 0 {
|
||||
echo (char newline) | autoview
|
||||
} {}
|
||||
}
|
||||
} | str collect
|
||||
|
@ -47,8 +47,8 @@ def run_ls [
|
|||
def log [
|
||||
message:any # Some log message
|
||||
] {
|
||||
let now = $(date now | date format '%Y%m%d_%H%M%S.%f')
|
||||
let mess = $(build-string $now '|DBG|' $message $(char newline))
|
||||
let now = (date now | date format '%Y%m%d_%H%M%S.%f')
|
||||
let mess = (build-string $now '|DBG|' $message (char newline))
|
||||
echo $mess | autoview
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
let m_table = $(
|
||||
let m_table = (
|
||||
echo [['name', 'tz', 'time']; ['andres' 'US/Eastern' ' '] ['fdncred' 'US/Central' ' '] ['gedge' 'US/Eastern' ' '] ['jturner' 'NZ' ' '] ['wycats' 'US/Pacific' ' ']]
|
||||
)
|
||||
let now = $(date now)
|
||||
let now = (date now)
|
||||
echo $m_table | update time {
|
||||
echo $now | date to-timezone $(get tz) | date format '%c'
|
||||
echo $now | date to-timezone (get tz) | date format '%c'
|
||||
}
|
|
@ -1,32 +1,32 @@
|
|||
# A Script to try and create the table for the readme.md file
|
||||
# | Category | File | Nu Version | Description |
|
||||
# | ---------------- | --------------------------------------------------------- | ---------- | ----------- |
|
||||
# | coloring | [color_table.nu](./coloring/color_table.nu) | 0.26 | desc |
|
||||
# | coloring | [color_tables.nu](./coloring/color_tables.nu) | 0.26 | desc |
|
||||
# | Category | File |
|
||||
# | ---------------- | ----------------------------------------------------------------------------- |
|
||||
# | coloring | [24bit-1.nu](./coloring\24bit-1.nu) |
|
||||
# | coloring | [color_table.nu](./coloring\color_table.nu) |
|
||||
# | coloring | [color_tables.nu](./coloring\color_tables.nu) |
|
||||
# | coloring | [gradient.nu](./coloring\gradient.nu) |
|
||||
|
||||
# Right now there is still manual manipulation in order to update the README.md
|
||||
# Hopefully, in the future someone will contribute a script to make this automatic.
|
||||
|
||||
let nu_files = $(ls **/*.nu)
|
||||
let nu_table = $(echo $nu_files |
|
||||
let nu_files = (ls **/*.nu)
|
||||
let nu_table = (echo $nu_files |
|
||||
get name |
|
||||
wrap File |
|
||||
insert 'Nu Version' 0.26 |
|
||||
insert Description desc |
|
||||
insert Category {
|
||||
let cat = $(get File | path dirname)
|
||||
wrap File |
|
||||
insert Category {
|
||||
let cat = (get File | path dirname)
|
||||
if $cat == "" {
|
||||
echo "not assigned yet"
|
||||
} {
|
||||
echo $cat
|
||||
}
|
||||
} | select Category File 'Nu Version' Description)
|
||||
} | where Category !~ ".git" | select Category File | sort-by Category)
|
||||
|
||||
# Let's fix the file now
|
||||
let nu_table = $(echo $nu_table | update File {
|
||||
let file_path = $(get File)
|
||||
let file_name = $(echo $file_path | path basename)
|
||||
let file_link = $(build-string "[" $file_name "]" "(./" $file_path ")")
|
||||
let nu_table = (echo $nu_table | update File {
|
||||
let file_path = (get File)
|
||||
let file_name = (echo $file_path | path basename)
|
||||
let file_link = (build-string "[" $file_name "]" "(./" $file_path ")")
|
||||
echo $file_link
|
||||
})
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
# 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
|
||||
let row = (build-string $it ' ')
|
||||
let data = (seq 40 49 | each {
|
||||
build-string $it ' '
|
||||
} | str collect)
|
||||
echo [$row $data $(char newline)] | str collect
|
||||
echo [$row $data (char newline)] | str collect
|
||||
} | str collect
|
|
@ -14,7 +14,7 @@ def nada [
|
|||
def nada2 [
|
||||
--flat(-f)
|
||||
] {
|
||||
let flat = $(= $flat | empty?)
|
||||
let flat = ($flat | empty?)
|
||||
|
||||
if $flat {
|
||||
echo $true
|
||||
|
|
|
@ -6,14 +6,13 @@ def look_for [word] {
|
|||
get shoes_name |
|
||||
split row " " |
|
||||
each --numbered {
|
||||
= [[idx, loc]; [$it.index, $(= $it.item | str index-of $word)]]
|
||||
[[idx, loc]; [$it.index, ($it.item | str index-of $word)]]
|
||||
}
|
||||
} |
|
||||
flatten |
|
||||
flatten |
|
||||
where comp.loc >= 0 |
|
||||
flatten |
|
||||
update idx { = $it.idx + 1 } |
|
||||
update idx { $it.idx + 1 } |
|
||||
reject name price loc |
|
||||
rename nameWords targetWordIndex
|
||||
}
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
def loading [] {
|
||||
echo Loading $(char newline) | str collect | autoview
|
||||
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
|
||||
echo (ansi -e '1000D') | autoview
|
||||
echo (build-string $it '%') | autoview
|
||||
}
|
||||
#show_cursor
|
||||
}
|
||||
|
||||
def show_cursor [] {
|
||||
echo $(ansi -e '?25h') | autoview
|
||||
echo (ansi -e '?25h') | autoview
|
||||
}
|
||||
|
||||
def hide_cursor [] {
|
||||
echo $(ansi -e '?25l') | autoview
|
||||
echo (ansi -e '?25l') | autoview
|
||||
}
|
||||
|
||||
hide_cursor
|
||||
|
|
|
@ -20,9 +20,9 @@ let blocks = ["▏" "▎" "▍" "▌" "▋" "▊" "▉" "█"]
|
|||
# "▏" #1/8
|
||||
|
||||
# Turn off the cursor
|
||||
echo $(ansi cursor_off)
|
||||
echo (ansi cursor_off)
|
||||
# Move cursor all the way to the left
|
||||
echo $(ansi -e '1000D') | autoview
|
||||
echo (ansi -e '1000D') | autoview
|
||||
# Draw the background for the progress bar
|
||||
echo $bg_fill | str lpad -c $bg_fill -l $pb_len
|
||||
|
||||
|
@ -33,19 +33,19 @@ echo 1..<$pb_len | each {
|
|||
|
||||
let cur_progress = $it
|
||||
echo 0..7 | each {
|
||||
let cur_idx = $(= $it mod 8)
|
||||
let cur_block = $(echo $blocks | nth $cur_idx)
|
||||
let cur_idx = ($it mod 8)
|
||||
let cur_block = (echo $blocks | nth $cur_idx)
|
||||
echo $cur_block | str lpad -c $blocks.7 -l $cur_progress | autoview
|
||||
echo $(ansi -e '1000D') | autoview
|
||||
echo (ansi -e '1000D') | autoview
|
||||
sleep 50ms
|
||||
}
|
||||
echo $(ansi -e '1000D') | autoview
|
||||
echo (ansi -e '1000D') | autoview
|
||||
}
|
||||
# Fill in the last background block
|
||||
echo $blocks.7 | str lpad -c $blocks.7 -l $pb_len | autoview
|
||||
echo $(char newline)
|
||||
echo (char newline)
|
||||
echo "Done"
|
||||
echo $(ansi cursor_on)
|
||||
echo (ansi cursor_on)
|
||||
|
||||
|
||||
# Try to do this in the next version
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
let blocks = ["▏" "▎" "▍" "▌" "▋" "▊" "▉" "█"]
|
||||
let pb_size = 25
|
||||
echo $(ansi cursor_off)
|
||||
echo (ansi cursor_off)
|
||||
echo 1..<$pb_size | each {
|
||||
let cur_size = $it
|
||||
echo 0..7 | each {
|
||||
let idx = $(= $it mod 8)
|
||||
let cur_block = $(echo $blocks | nth $idx)
|
||||
let idx = ($it mod 8)
|
||||
let cur_block = (echo $blocks | nth $idx)
|
||||
echo $cur_block | str lpad -c $blocks.7 -l $cur_size | autoview
|
||||
echo $(ansi -e '1000D') | autoview
|
||||
echo (ansi -e '1000D') | autoview
|
||||
sleep 50ms
|
||||
}
|
||||
}
|
||||
echo $(char newline)
|
||||
echo (char newline)
|
||||
echo 'Done'
|
||||
echo $(ansi cursor_on)
|
||||
echo (ansi cursor_on)
|
||||
|
||||
|
|
|
@ -1,38 +1,41 @@
|
|||
# Displays a prompt
|
||||
def git-status-prompt [] {
|
||||
build-string $(ansi reset) $(ansi green) $(whoami | str trim) $(ansi reset) @ $(hostname -s | str trim) : $(ansi green_dimmed) $(prompt-pwd) $(ansi reset) $(git-branch-icon) $(ansi reset) $(char newline) '➤ '
|
||||
# build-string (ansi reset) (ansi green) (whoami | str trim) (ansi reset) '@' ((sys).host | get hostname) ':' (ansi green_dimmed) (prompt-pwd) (ansi reset) (git-branch-icon) (ansi reset) (char newline) '➤ '
|
||||
let not_windows = (echo $nu.path | first | into string | str contains '/')
|
||||
build-string (ansi reset) (ansi green) (if $not_windows {$nu.env.USER} {$nu.env.USERNAME}) (ansi reset) '@' (hostname | str trim) ':' (ansi green_dimmed) (prompt-pwd) (ansi reset) (git-branch-icon) (ansi reset) (char newline) '➤ '
|
||||
}
|
||||
|
||||
# Returns a shortened pwd for use in prompt
|
||||
def prompt-pwd [] {
|
||||
let path = $(pwd | split row "/")
|
||||
let home = $(echo $nu.env.HOME | split row "/")
|
||||
let not_windows = (echo $nu.path | first | into string | str contains '/')
|
||||
let path = (pwd | if $not_windows { split row "/" } { split row "\" })
|
||||
let home = (if $not_windows { ($nu.env.HOME | split row "/") } { (echo [$nu.env.HOMEDRIVE $nu.env.HOMEPATH] | path join | split row "\") })
|
||||
|
||||
if $(echo $path | count) > 1 {
|
||||
if $(echo $home | reduce { = $it in $path }) {
|
||||
let path-without-home = $(echo $path | skip $(echo $home | count))
|
||||
if (echo $path | length) > 1 {
|
||||
if (echo $home | reduce { $it in $path }) {
|
||||
let path-without-home = (echo $path | skip (echo $home | length))
|
||||
|
||||
if $(echo $path-without-home | wrap | compact | count) > 0 {
|
||||
let parent = $(echo $path | skip $(echo $home | count) | drop)
|
||||
if (echo $path-without-home | wrap | compact | length) > 0 {
|
||||
let parent = (echo $path | skip (echo $home | length) | drop)
|
||||
|
||||
if $(echo $parent | wrap | compact | count) > 0 {
|
||||
let short-part = $(echo $parent | each {
|
||||
if $(echo $it | str starts-with ".") {
|
||||
echo $(echo $it | str substring [0 2]) "/"
|
||||
if (echo $parent | wrap | compact | length) > 0 {
|
||||
let short-part = (echo $parent | each {
|
||||
if (echo $it | str starts-with ".") {
|
||||
echo (echo $it | str substring [0 2]) "/"
|
||||
} {
|
||||
echo $(echo $it | str substring [0 1]) "/"
|
||||
echo (echo $it | str substring [0 1]) "/"
|
||||
}
|
||||
})
|
||||
echo "~/" $short-part $(echo $path | last) | str collect
|
||||
echo "~/" $short-part (echo $path | last) | str collect
|
||||
} {
|
||||
echo "~/" $(echo $path | last) | str collect
|
||||
echo "~/" (echo $path | last) | str collect
|
||||
}
|
||||
} {
|
||||
echo "~"
|
||||
}
|
||||
} {
|
||||
let parent = $(echo $path | drop | str substring [0 1] | each { echo $it "/" })
|
||||
echo "/" $parent $(echo $path | last) | str collect
|
||||
let parent = (echo $path | drop | str substring [0 1] | each { echo $it "/" })
|
||||
echo "/" $parent (echo $path | last) | str collect
|
||||
}
|
||||
} {
|
||||
pwd
|
||||
|
@ -42,10 +45,10 @@ def prompt-pwd [] {
|
|||
# Map of git status codes to ANSI colour codes
|
||||
def git-prompt-map [] {
|
||||
echo a m r c d "??" u |
|
||||
rotate counter-clockwise |
|
||||
reject Column0 | append $(
|
||||
echo $(ansi green) $(ansi yellow_bold) $(ansi cyan) $(ansi blue) $(ansi red) $(ansi red_dimmed) $(ansi red) |
|
||||
rotate counter-clockwise |
|
||||
rotate lengther-clockwise |
|
||||
reject Column0 | append (
|
||||
echo (ansi green) (ansi yellow_bold) (ansi cyan) (ansi blue) (ansi red) (ansi red_dimmed) (ansi red) |
|
||||
rotate lengther-clockwise |
|
||||
reject Column0
|
||||
) | headers
|
||||
}
|
||||
|
@ -59,7 +62,7 @@ def git-prompt-icons [k] {
|
|||
let idx = $it.index;
|
||||
|
||||
if $it.item.status == $k {
|
||||
build-string $it.item.colour $(echo $icns | nth $idx)
|
||||
build-string $it.item.colour (echo $icns | nth $idx)
|
||||
} {
|
||||
= $nothing
|
||||
}
|
||||
|
@ -69,21 +72,21 @@ def git-prompt-icons [k] {
|
|||
# Checks git status of current working directory and displays an icon
|
||||
def git-branch-icon [] {
|
||||
do -i {
|
||||
let branch = $(do -i { git rev-parse --abbrev-ref HEAD } | str trim)
|
||||
|
||||
if $(echo $branch | str length) > 0 {
|
||||
let modified = $(do -i { git status --porcelain } | split row "\n" | str trim | split column " " status file);
|
||||
let branch = (do -i { git rev-parse --abbrev-ref HEAD } | str trim)
|
||||
|
||||
if $(echo $modified | get | first | empty?) {
|
||||
build-string "|" $(ansi green) $branch $(ansi reset) ":" $(ansi green) '✓' $(ansi reset)
|
||||
if (echo $branch | str length) > 0 {
|
||||
let modified = (do -i { git status --porcelain } | split row "\n" | str trim | split column " " status file);
|
||||
|
||||
if (echo $modified | get | first | empty?) {
|
||||
build-string "|" (ansi green) $branch (ansi reset) ":" (ansi green) '✓' (ansi reset)
|
||||
} {
|
||||
let modified2 = $(do -i { git status --porcelain } | split row "\n" | str substring [0 1])
|
||||
let branch-colour = $(if $(echo $modified2 | each { = $it in [A M R C D] } | reduce { = $it || $acc }) {
|
||||
let modified2 = (do -i { git status --porcelain } | split row "\n" | str substring [0 1])
|
||||
let branch-colour = (if (echo $modified2 | each { $it in [A M R C D] } | reduce { $it || $acc }) {
|
||||
echo yellow
|
||||
} {
|
||||
echo red
|
||||
})
|
||||
build-string "|" $(ansi $branch-colour) $branch $(ansi reset) ":" $(echo $modified | get status | uniq | str downcase | each {
|
||||
build-string "|" (ansi $branch-colour) $branch (ansi reset) ":" (echo $modified | get status | uniq | str downcase | each {
|
||||
git-prompt-icons $it
|
||||
} | str collect)
|
||||
}
|
||||
|
|
|
@ -1,49 +1,49 @@
|
|||
# This is a work in progress. Not working yet but you can see where I'm going.
|
||||
def construct_prompt [] {
|
||||
# let decorator = $(char prompt)
|
||||
let decorator = $(create_second_line)
|
||||
# let decorator = (char prompt)
|
||||
let decorator = (create_second_line)
|
||||
|
||||
# not using machine name
|
||||
# let machine_name = $(sys | get host.hostname)
|
||||
# let machine_name = (sys | get host.hostname)
|
||||
|
||||
# the current working directory
|
||||
# let current_dir = $(pwd)
|
||||
let current_dir = $(home_abbrev)
|
||||
# let current_dir = (pwd)
|
||||
let current_dir = (home_abbrev)
|
||||
|
||||
# the current bit branch
|
||||
# let git_status = $(git -c core.quotepath=false -c color.status=false status -uall --short --branch)
|
||||
let git_info = $(do -i { git rev-parse --abbrev-ref HEAD } | str trim | str collect )
|
||||
# let git_status = (git -c core.quotepath=false -c color.status=false status -uall --short --branch)
|
||||
let git_info = (do -i { git rev-parse --abbrev-ref HEAD } | str trim | str collect )
|
||||
|
||||
# what to put in the title
|
||||
let title_bar = $(set_title)
|
||||
let title_bar = (set_title)
|
||||
|
||||
# get the terminal width
|
||||
let term_width = $(term size -w)
|
||||
let term_width = (term size -w)
|
||||
|
||||
# get the curren time
|
||||
let current_time = $(date now | date format '%I:%M:%S%.3f %p')
|
||||
let current_time = (date now | date format '%I:%M:%S%.3f %p')
|
||||
|
||||
# let's construct the left and right prompt
|
||||
# the left side of the prompt with ansi colors
|
||||
let left_colored = $(build-string $(ansi gb) $current_dir $(ansi cb) '(' $git_info ')' $(ansi reset))
|
||||
let left_colored = (build-string (ansi gb) $current_dir (ansi cb) '(' $git_info ')' (ansi reset))
|
||||
|
||||
# the left prompt length without the ansi escapes
|
||||
let left_len = $(echo $left_colored | ansi strip | str length)
|
||||
let left_len = (echo $left_colored | ansi strip | str length)
|
||||
|
||||
# the right side of the prompt with ansi colors
|
||||
let right_colored = $(build-string $(ansi blue) $(echo $nu.env.CMD_DURATION) '|' $(ansi dark_gray) $current_time $(ansi reset))
|
||||
let right_colored = (build-string (ansi blue) (echo $nu.env.CMD_DURATION) '|' (ansi dark_gray) $current_time (ansi reset))
|
||||
|
||||
# the right prompt length *with* ansi escapes (need this to determine how many escape chars there are)
|
||||
let right_colored_len = $(echo $right_colored | str length)
|
||||
let right_colored_len = (echo $right_colored | str length)
|
||||
|
||||
# the right prompt length without the ansi escapes
|
||||
let right_len = $(echo $right_colored | ansi strip | str length)
|
||||
let right_len = (echo $right_colored | ansi strip | str length)
|
||||
|
||||
# let's calcuate the length of the right prompt so we know how much to pad the left prompt
|
||||
let calculated_right_len = $(= $term_width - $left_len + ($right_colored_len - $right_len))
|
||||
let calculated_right_len = ($term_width - $left_len + ($right_colored_len - $right_len))
|
||||
|
||||
# finally, let's make the prompt
|
||||
let the_prompt = $(build-string $left_colored $(echo $right_colored | str lpad -c ' ' -l $calculated_right_len) $(char newline) $decorator ' ')
|
||||
let the_prompt = (build-string $left_colored (echo $right_colored | str lpad -c ' ' -l $calculated_right_len) (char newline) $decorator ' ')
|
||||
|
||||
# let's update the title bar now
|
||||
echo $title_bar
|
||||
|
@ -60,37 +60,37 @@ def construct_prompt [] {
|
|||
|
||||
# Abbreviate home path
|
||||
def home_abbrev [] {
|
||||
let is_home_in_path = $(echo $(pwd) | str starts-with $nu.home-dir)
|
||||
let is_home_in_path = (echo (pwd) | str starts-with $nu.home-dir)
|
||||
if $is_home_in_path {
|
||||
let lin-home = $(echo $nu.home-dir | str find-replace -a '\\' '/' | str downcase)
|
||||
let lin-pwd = $(echo $(pwd) | str find-replace -a '\\' '/' | str downcase)
|
||||
let lin-home = (echo $nu.home-dir | str find-replace -a '\\' '/' | str downcase)
|
||||
let lin-pwd = (echo (pwd) | str find-replace -a '\\' '/' | str downcase)
|
||||
echo $lin-pwd | str find-replace $lin-home '~'
|
||||
} {
|
||||
echo $(pwd)
|
||||
echo (pwd)
|
||||
}
|
||||
}
|
||||
|
||||
# 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
|
||||
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 ' ' $(char bel)] | str collect
|
||||
echo [(ansi title) ' ' $str-arg ' ' (char bel)] | str collect
|
||||
}
|
||||
def get_abbrev_pwd_win [] {
|
||||
echo [$(pwd | split row '\' | first $(pwd | split row '\' | length | each {= $it - 1} ) | str substring '0,1' | format '{$it}/' | append $(pwd | split row '\' | last ) | str collect)] | str collect
|
||||
echo [(pwd | split row '\' | first (pwd | split row '\' | length | 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 '/' | length | each {= $it - 1} ) | each { str substring '0,1' | format '{$it}/' } | append $(pwd | split row '/' | last ) | str collect)] | str collect
|
||||
echo [$(home_abbrev | split row '/' | first $(home_abbrev | split row '/' | length | each {= $it - 1} ) | each { str substring '0,1' | format '{$it}/' } | append $(home_abbrev | split row '/' | last ) | str collect)] | str collect
|
||||
# echo [(pwd | split row '/' | first (pwd | split row '/' | length | each { $it - 1} ) | each { str substring '0,1' | format '{$it}/' } | append (pwd | split row '/' | last ) | str collect)] | str collect
|
||||
echo [(home_abbrev | split row '/' | first (home_abbrev | split row '/' | length | each { $it - 1} ) | each { str substring '0,1' | format '{$it}/' } | append (home_abbrev | split row '/' | last ) | str collect)] | str collect
|
||||
}
|
||||
def set_title [] {
|
||||
set_title_str $(build-string $(get_abbrev_pwd_lin) ' ' $(term size -w) 'x' $(term size -t) | str collect)
|
||||
set_title_str (build-string (get_abbrev_pwd_lin) ' ' (term size -w) 'x' (term size -t) | str collect)
|
||||
}
|
||||
def create_second_line [] {
|
||||
build-string $(ansi gb) $(char -u "2514") $(char -u "2500") ' $ ' $(ansi cb) $(char prompt) $(ansi reset)
|
||||
build-string (ansi gb) (char -u "2514") (char -u "2500") ' $ ' (ansi cb) (char prompt) (ansi reset)
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
# Example: sys | flatter 3
|
||||
def flatter [levels:int] {
|
||||
if $levels > 0 {
|
||||
flatten | flatter $(= $levels - 1)
|
||||
flatten | flatter ($levels - 1)
|
||||
} {
|
||||
each { echo $it }
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ def get-col [
|
|||
] {
|
||||
|
||||
# meant to be used like `ls | get-col 1`
|
||||
# ls | select $(ls | get | nth 2)
|
||||
|
||||
# ls | select (ls | get | nth 2)
|
||||
|
||||
each {
|
||||
echo $it | select $(echo $it | get | nth $col_index)
|
||||
echo $it | select (echo $it | get | nth $col_index)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
# A small script to auto-update nushell in linux
|
||||
# WIP - Not finished yet
|
||||
def get-latest [] {
|
||||
let metadata = $(fetch https://api.github.com/repos/nushell/nushell/releases/latest)
|
||||
let release_name = $(echo $metadata | get name | split row ' ' | nth 0)
|
||||
let body = $(echo $metadata | get body)
|
||||
let asset_info = $(echo $metadata | get assets | where name =~ 'linux.tar.gz')
|
||||
let download_url = $(echo $asset_info | get browser_download_url)
|
||||
let file_name = $(echo $asset_info | get name)
|
||||
echo $(build-string "Release name is " $release_name $(char newline) $(char newline))
|
||||
echo $(build-string $body $(char newline) $(char newline) "Downloading...")
|
||||
let redirected_url = $(fetch $download_url --raw)
|
||||
let real_download_url = $(echo $redirected_url | xpath '//@href' | get '//@href')
|
||||
let metadata = (fetch https://api.github.com/repos/nushell/nushell/releases/latest)
|
||||
let release_name = (echo $metadata | get name | split row ' ' | nth 0)
|
||||
let body = (echo $metadata | get body)
|
||||
let asset_info = (echo $metadata | get assets | where name =~ 'linux.tar.gz')
|
||||
let download_url = (echo $asset_info | get browser_download_url)
|
||||
let file_name = (echo $asset_info | get name)
|
||||
echo (build-string "Release name is " $release_name (char newline) (char newline))
|
||||
echo (build-string $body (char newline) (char newline) "Downloading...")
|
||||
let redirected_url = (fetch $download_url --raw)
|
||||
let real_download_url = (echo $redirected_url | xpath '//@href' | get '//@href')
|
||||
fetch $real_download_url | save $file_name
|
||||
# Remaining to do
|
||||
# tar xf $file_name
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# This is a first attempt and some type of logging
|
||||
def log [message:any] {
|
||||
let now = $(date now | date format '%Y%m%d_%H%M%S.%f')
|
||||
let mess = $(build-string $now '|DBG|' $message $(char newline))
|
||||
let now = (date now | date format '%Y%m%d_%H%M%S.%f')
|
||||
let mess = (build-string $now '|DBG|' $message (char newline))
|
||||
echo $mess | autoview
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
# 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
|
||||
# echo (fg_blue) Darren (relet) ' ' Schroeder | str collect
|
||||
# More examples in the short_list.nu script
|
||||
|
||||
alias fmt_error = ansi -e '31;1m'
|
||||
|
@ -28,8 +28,8 @@ 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 }
|
||||
# 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'
|
||||
|
@ -59,7 +59,7 @@ def fg_from_rgb [
|
|||
green:int # green component 0-255
|
||||
blue:int # blue component 0-255
|
||||
] {
|
||||
echo [$(ansi -e '38;2;') $red ';' $green ';' $blue 'm'] | str collect
|
||||
echo [(ansi -e '38;2;') $red ';' $green ';' $blue 'm'] | str collect
|
||||
}
|
||||
|
||||
alias bg_black = ansi -e '40m'
|
||||
|
@ -92,19 +92,19 @@ def bg_from_rgb [
|
|||
green:int # green component 0-255
|
||||
blue:int # blue component 0-255
|
||||
] {
|
||||
echo [$(ansi -e '48;2;') $red ';' $green ';' $blue 'm'] | str collect
|
||||
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
|
||||
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
|
||||
echo [(ansi -e '48;5;') $idx 'm'] | str collect
|
||||
}
|
|
@ -4,13 +4,13 @@ def print [
|
|||
--separator(-s):any # Optional separator (not yet flagged as optional?)
|
||||
...rest # All of the parameters
|
||||
] {
|
||||
let is_empty = $(= $separator | empty?)
|
||||
let num_of_rest = $(echo $rest | length)
|
||||
let is_empty = ($separator | empty?)
|
||||
let num_of_rest = (echo $rest | length)
|
||||
echo $rest | each --numbered {
|
||||
if $is_empty {
|
||||
build-string $it.item
|
||||
} {
|
||||
if $num_of_rest > $(= $it.index + 1) {
|
||||
if $num_of_rest > ($it.index + 1) {
|
||||
build-string $it.item $separator
|
||||
} {
|
||||
build-string $it.item
|
||||
|
@ -32,8 +32,8 @@ def print2 [
|
|||
--separator(-s):any # Optional separator (not yet flagged as optional?)
|
||||
...rest # All of the parameters
|
||||
] {
|
||||
let is_empty = $(= $separator | empty?)
|
||||
let num_of_rest = $(echo $rest | length)
|
||||
let is_empty = ($separator | empty?)
|
||||
let num_of_rest = (echo $rest | length)
|
||||
if $is_empty {
|
||||
echo $rest | str from | str collect
|
||||
} {
|
||||
|
@ -52,31 +52,31 @@ def print3 [
|
|||
--flat(-f) # If tables are found, flatten them
|
||||
...rest # All of the parameters
|
||||
] {
|
||||
let sep_empty = $(= $separator | empty?)
|
||||
let num_of_rest = $(echo $rest | length)
|
||||
let flat = $(= $flat | empty?)
|
||||
let sep_empty = ($separator | empty?)
|
||||
let num_of_rest = (echo $rest | length)
|
||||
let flat = ($flat | empty?)
|
||||
echo $rest | each --numbered {
|
||||
if $sep_empty {
|
||||
#log 'sep is empty'
|
||||
if $(echo $it.item | length) > 1 && $flat {
|
||||
if (echo $it.item | length) > 1 && $flat {
|
||||
#log 'flatten please'
|
||||
let flatter = $(echo $it.item | flatten | str from | str collect)
|
||||
let flatter = (echo $it.item | flatten | str from | str collect)
|
||||
build-string $flatter
|
||||
} {
|
||||
#log 'no flat'
|
||||
build-string $it.item
|
||||
}
|
||||
} {
|
||||
if $num_of_rest > $(= $it.index + 1) {
|
||||
if $(echo $it.item | length) > 1 && $flat {
|
||||
let flatter = $(echo $it.item | flatten | str from | str collect $separator)
|
||||
if $num_of_rest > ($it.index + 1) {
|
||||
if (echo $it.item | length) > 1 && $flat {
|
||||
let flatter = (echo $it.item | flatten | str from | str collect $separator)
|
||||
build-string $flatter $separator
|
||||
} {
|
||||
build-string $it.item $separator
|
||||
}
|
||||
} {
|
||||
if $(echo $it.item | length) > 1 && $flat {
|
||||
let flatter = $(echo $it.item | flatten | str from | str collect $separator)
|
||||
if (echo $it.item | length) > 1 && $flat {
|
||||
let flatter = (echo $it.item | flatten | str from | str collect $separator)
|
||||
build-string $flatter
|
||||
} {
|
||||
build-string $it.item
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
let table = $(echo [
|
||||
let table = (echo [
|
||||
[url user_login title
|
||||
]; [https://api.github.com/repos/nushell/nushell/issues/3382 ammkrn 'Dont unwrap rustyline helper in cli'
|
||||
] [https://api.github.com/repos/nushell/nushell/issues/3379 jonathandturner 'Simplify down to one type of context'
|
||||
|
@ -9,23 +9,25 @@ let table = $(echo [
|
|||
] [https://api.github.com/repos/nushell/nushell/issues/3367 fdncred 'tweaked the error handling to show specific errors']
|
||||
])
|
||||
|
||||
# Show what the table looks like
|
||||
echo $table
|
||||
|
||||
build-string '## Nushell' $(char nl) $(char nl)
|
||||
# Now show what the table in Markdown looks like
|
||||
build-string '## Nushell' (char nl) (char nl)
|
||||
echo $table | group-by user_login | pivot user prs | each {
|
||||
let user_name = $it.user
|
||||
let pr_count = $(echo $it.prs | length)
|
||||
let pr_count = (echo $it.prs | length)
|
||||
|
||||
# only print the comma if there's another item
|
||||
let user_prs = $(echo $it.prs | each -n {
|
||||
if $pr_count == $(= $it.index + 1) {
|
||||
let user_prs = (echo $it.prs | each -n {
|
||||
if $pr_count == ($it.index + 1) {
|
||||
build-string '[' $it.item.title '](' $it.item.url ')'
|
||||
} {
|
||||
build-string '[' $it.item.title '](' $it.item.url '), and '
|
||||
}
|
||||
} | str collect)
|
||||
|
||||
build-string '- ' $user_name ' created ' $user_prs $(char nl)
|
||||
build-string '- ' $user_name ' created ' $user_prs (char nl)
|
||||
} | str collect
|
||||
|
||||
# ╭───┬──────────────────────────────────────────────────────────┬─────────────────┬───────────────────────────────────────────────────────╮
|
||||
|
@ -41,7 +43,7 @@ echo $table | group-by user_login | pivot user prs | each {
|
|||
# ╰───┴──────────────────────────────────────────────────────────┴─────────────────┴───────────────────────────────────────────────────────╯
|
||||
|
||||
def log [message:any] {
|
||||
let now = $(date now | date format '%Y%m%d_%H%M%S.%f')
|
||||
let mess = $(build-string $now '|DBG|' $message $(char newline))
|
||||
let now = (date now | date format '%Y%m%d_%H%M%S.%f')
|
||||
let mess = (build-string $now '|DBG|' $message (char newline))
|
||||
echo $mess | autoview
|
||||
}
|
||||
|
|
24
temp.nu
24
temp.nu
|
@ -4,7 +4,7 @@ def "temp f-to-c" [
|
|||
] {
|
||||
# (100°F − 32) × 5/9 = 37.778°C
|
||||
|
||||
let celcius = $(= $(= $fahren - 32) * 5 / 9)
|
||||
let celcius = (($fahren - 32) * 5 / 9)
|
||||
build-string $fahren ' °F is ' $celcius ' °C'
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ def "temp f-to-k" [
|
|||
] {
|
||||
# (100°F − 32) × 5/9 + 273.15 = 310.928K
|
||||
|
||||
let kelvin = $(= $(= $fahren - 32) * 5 / 9 + 273.15)
|
||||
let kelvin = (($fahren - 32) * 5 / 9 + 273.15)
|
||||
build-string $fahren ' °F is ' $kelvin ' °K'
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ def "temp c-to-f" [
|
|||
] {
|
||||
# (100°C × 9/5) + 32 = 212°F
|
||||
|
||||
let fahren = $(= $(= $celcius * 9 / 5) + 32)
|
||||
let fahren = (($celcius * 9 / 5) + 32)
|
||||
build-string $celcius ' °C is ' $fahren ' °F'
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ def "temp c-to-k" [
|
|||
] {
|
||||
# 100°C + 273.15 = 373.15K
|
||||
|
||||
let kelvin = $(= $celcius + 273.15)
|
||||
let kelvin = ($celcius + 273.15)
|
||||
build-string $celcius ' °C is ' $kelvin ' °K'
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ def "temp k-to-f" [
|
|||
] {
|
||||
# (100K − 273.15) × 9/5 + 32 = -279.7°F
|
||||
|
||||
let fahren = $(= $(= $kelvin - 273.15) * 9 / 5 + 32)
|
||||
let fahren = (($kelvin - 273.15) * 9 / 5 + 32)
|
||||
build-string $kelvin ' °K is ' $fahren ' °F'
|
||||
}
|
||||
|
||||
|
@ -54,19 +54,19 @@ def "temp k-to-c" [
|
|||
] {
|
||||
# 100K − 273.15 = -173.1°C
|
||||
|
||||
let celcius = $(= $kelvin - 273.15)
|
||||
let celcius = ($kelvin - 273.15)
|
||||
build-string $kelvin ' °K is ' $celcius ' °C'
|
||||
}
|
||||
|
||||
temp f-to-c 100
|
||||
echo $(char nl)
|
||||
echo (char nl)
|
||||
temp f-to-k 100
|
||||
echo $(char nl)
|
||||
echo (char nl)
|
||||
temp c-to-f 100
|
||||
echo $(char nl)
|
||||
echo (char nl)
|
||||
temp c-to-k 100
|
||||
echo $(char nl)
|
||||
echo (char nl)
|
||||
temp k-to-f 100
|
||||
echo $(char nl)
|
||||
echo (char nl)
|
||||
temp k-to-c 100
|
||||
echo $(char nl)
|
||||
echo (char nl)
|
||||
|
|
|
@ -15,39 +15,39 @@ def do-work [] {
|
|||
]
|
||||
|
||||
let query_prefix = "https://api.github.com/search/issues?q=repo:nushell/"
|
||||
let query_date = $(seq date --days 7 -r | last)
|
||||
let query_suffix = $(build-string "+is:pr+is:merged+merged:%3E%3D" $query_date)
|
||||
let query_date = (seq date --days 7 -r | last)
|
||||
let query_suffix = (build-string "+is:pr+is:merged+merged:%3E%3D" $query_date)
|
||||
|
||||
let entries = $(echo $site_table | each {
|
||||
let query_string = $(build-string $query_prefix $it.repo $query_suffix)
|
||||
let site_json = $(fetch $query_string | get items | select html_url user.login title body)
|
||||
build-string '## ' $(echo $it.site) $(char nl) $(char nl)
|
||||
if $(= $site_json | empty?) {
|
||||
build-string "none found this week" $(char nl) $(char nl)
|
||||
let entries = (echo $site_table | each {
|
||||
let query_string = (build-string $query_prefix $it.repo $query_suffix)
|
||||
let site_json = (fetch $query_string | get items | select html_url user.login title body)
|
||||
build-string '## ' (echo $it.site) (char nl) (char nl)
|
||||
if ($site_json | all? ($it | empty?)) {
|
||||
build-string "none found this week" (char nl) (char nl)
|
||||
} {
|
||||
echo $site_json | group-by user_login | pivot user prs | each {
|
||||
let user_name = $it.user
|
||||
let pr_count = $(echo $it.prs | length)
|
||||
let pr_count = (echo $it.prs | length)
|
||||
|
||||
# only print the comma if there's another item
|
||||
let user_prs = $(echo $it.prs | each -n {
|
||||
if $pr_count == $(= $it.index + 1) {
|
||||
build-string $(char nl) '### [' $it.item.title '](' $it.item.html_url ')' $(char nl) $(char nl) $it.item.body $(char nl)
|
||||
let user_prs = (echo $it.prs | each -n {
|
||||
if $pr_count == ($it.index + 1) {
|
||||
build-string (char nl) '### [' $it.item.title '](' $it.item.html_url ')' (char nl) (char nl) $it.item.body (char nl)
|
||||
} {
|
||||
build-string $(char nl) '### [' $it.item.title '](' $it.item.html_url ')' $(char nl) $(char nl) $it.item.body $(char nl) 'and' $(char nl)
|
||||
build-string (char nl) '### [' $it.item.title '](' $it.item.html_url ')' (char nl) (char nl) $it.item.body (char nl) 'and' (char nl)
|
||||
}
|
||||
} | str collect)
|
||||
|
||||
build-string '### **' $user_name '** ' $(char nl) $(char nl) '---' $(char nl) $user_prs $(char nl)
|
||||
build-string '### **' $user_name '** ' (char nl) (char nl) '---' (char nl) $user_prs (char nl)
|
||||
} | str collect
|
||||
build-string $(char nl)
|
||||
build-string (char nl)
|
||||
}
|
||||
|
||||
# We need 2 seconds between fetches or github's api limiting will limit us
|
||||
sleep 2sec
|
||||
})
|
||||
|
||||
if $(= $entries | empty?) {
|
||||
if ($entries | empty?) {
|
||||
|
||||
} {
|
||||
echo $entries | str collect
|
||||
|
@ -55,6 +55,6 @@ def do-work [] {
|
|||
}
|
||||
|
||||
# 2019-08-23 was the release of 0.2.0, the first public release
|
||||
let week_num = $(seq date -b '2019-08-23' -n 7 | length)
|
||||
build-string '# This week in Nushell #' $week_num $(char nl) $(char nl)
|
||||
let week_num = (seq date -b '2019-08-23' -n 7 | length)
|
||||
build-string '# This week in Nushell #' $week_num (char nl) (char nl)
|
||||
do-work | str collect
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue