mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
replace occurences of str collect
with str join
(#436)
This commit is contained in:
parent
2cc5b58209
commit
b7a45fbcca
29 changed files with 117 additions and 117 deletions
|
@ -2,7 +2,7 @@
|
||||||
def wolfram [...query #Your query
|
def wolfram [...query #Your query
|
||||||
] {
|
] {
|
||||||
let appID = #YOUR APP_ID
|
let appID = #YOUR APP_ID
|
||||||
let query_string = ($query | str collect " ")
|
let query_string = ($query | str join " ")
|
||||||
let result = (fetch ("https://api.wolframalpha.com/v1/result?" + ([[appid i]; [$appID $query_string]] | to url)))
|
let result = (fetch ("https://api.wolframalpha.com/v1/result?" + ([[appid i]; [$appID $query_string]] | to url)))
|
||||||
$result + ""
|
$result + ""
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ def wolfram [...query #Your query
|
||||||
def wolframimg [...query #Your query
|
def wolframimg [...query #Your query
|
||||||
] {
|
] {
|
||||||
let appID = #YOUR APP_ID
|
let appID = #YOUR APP_ID
|
||||||
let query_string = ($query | str collect " ")
|
let query_string = ($query | str join " ")
|
||||||
let filename = ($query_string + ".png")
|
let filename = ($query_string + ".png")
|
||||||
let link = ("https://api.wolframalpha.com/v1/simple?" + ([[appid i]; [$appID $query_string]] | to url) + "&background=F5F5F5&fontsize=20")
|
let link = ("https://api.wolframalpha.com/v1/simple?" + ([[appid i]; [$appID $query_string]] | to url) + "&background=F5F5F5&fontsize=20")
|
||||||
fetch $link | save $filename
|
fetch $link | save $filename
|
||||||
echo ("Query result saved in file: " + $filename)
|
echo ("Query result saved in file: " + $filename)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ export alias select-aws-profile = (
|
||||||
hide AWS_REGION;
|
hide AWS_REGION;
|
||||||
(do {
|
(do {
|
||||||
let creds = (open ($env.HOME + "/.aws/credentials") | from ini)
|
let creds = (open ($env.HOME + "/.aws/credentials") | from ini)
|
||||||
let selectedProfile = (for it in ($creds | transpose name creds) { echo $it.name } | str collect "\n" | fzf | str trim)
|
let selectedProfile = (for it in ($creds | transpose name creds) { echo $it.name } | str join "\n" | fzf | str trim)
|
||||||
if $selectedProfile != "" {
|
if $selectedProfile != "" {
|
||||||
let out = {
|
let out = {
|
||||||
AWS_PROFILE: $selectedProfile,
|
AWS_PROFILE: $selectedProfile,
|
||||||
|
|
|
@ -14,7 +14,7 @@ seq 0 $height | par-each {|| # create these in parallel
|
||||||
} else {
|
} else {
|
||||||
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
|
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
print -n $"($row_data)" | table
|
print -n $"($row_data)" | table
|
||||||
$nothing
|
$nothing
|
||||||
} | compact
|
} | compact
|
||||||
|
|
|
@ -14,9 +14,9 @@ seq 0 $height | each { |row|
|
||||||
} else {
|
} else {
|
||||||
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
|
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
print -n $"($row_data)(char newline)"
|
print -n $"($row_data)(char newline)"
|
||||||
} | str collect
|
} | str join
|
||||||
|
|
||||||
def iter_inc [incr mult iter] {
|
def iter_inc [incr mult iter] {
|
||||||
$incr + $mult * $iter
|
$incr + $mult * $iter
|
||||||
|
|
|
@ -22,9 +22,9 @@ if ($is_release | str downcase | str trim) == "y" {
|
||||||
} else {
|
} else {
|
||||||
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
|
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
$"($row_data)(char newline)"
|
$"($row_data)(char newline)"
|
||||||
} | str collect
|
} | str join
|
||||||
} | math avg)
|
} | math avg)
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,9 +42,9 @@ if ($is_release | str downcase | str trim) == "y" {
|
||||||
} else {
|
} else {
|
||||||
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
|
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
$"($row_data)(char cr)"
|
$"($row_data)(char cr)"
|
||||||
} | str collect
|
} | str join
|
||||||
} | math avg)
|
} | math avg)
|
||||||
|
|
||||||
print $"running test 2 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
print $"running test 2 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||||
|
@ -61,9 +61,9 @@ if ($is_release | str downcase | str trim) == "y" {
|
||||||
} else {
|
} else {
|
||||||
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
|
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
$"($row_data)(char cr)"
|
$"($row_data)(char cr)"
|
||||||
} | str collect
|
} | str join
|
||||||
} | math avg)
|
} | math avg)
|
||||||
|
|
||||||
print $"running test 3 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
print $"running test 3 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||||
|
@ -82,9 +82,9 @@ if ($is_release | str downcase | str trim) == "y" {
|
||||||
} else {
|
} else {
|
||||||
$"($ansi1)($fgcolor)m(char sp)($ansi2)"
|
$"($ansi1)($fgcolor)m(char sp)($ansi2)"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
$"($row_data)(char cr)"
|
$"($row_data)(char cr)"
|
||||||
} | str collect
|
} | str join
|
||||||
} | math avg)
|
} | math avg)
|
||||||
|
|
||||||
print $"running test 4 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
print $"running test 4 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||||
|
@ -101,9 +101,9 @@ if ($is_release | str downcase | str trim) == "y" {
|
||||||
} else {
|
} else {
|
||||||
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
|
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
$"($row_data)(char cr)"
|
$"($row_data)(char cr)"
|
||||||
} | str collect
|
} | str join
|
||||||
} | math avg)
|
} | math avg)
|
||||||
|
|
||||||
print $"running test 5 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
print $"running test 5 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||||
|
@ -120,9 +120,9 @@ if ($is_release | str downcase | str trim) == "y" {
|
||||||
} else {
|
} else {
|
||||||
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
|
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
$"($row_data)(char cr)"
|
$"($row_data)(char cr)"
|
||||||
} | str collect
|
} | str join
|
||||||
} | math avg)
|
} | math avg)
|
||||||
|
|
||||||
print $"running test 6 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
print $"running test 6 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||||
|
@ -139,9 +139,9 @@ if ($is_release | str downcase | str trim) == "y" {
|
||||||
} else {
|
} else {
|
||||||
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
|
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
$"($row_data)(char cr)"
|
$"($row_data)(char cr)"
|
||||||
} | str collect
|
} | str join
|
||||||
} | math avg)
|
} | math avg)
|
||||||
|
|
||||||
print 'collating tests'
|
print 'collating tests'
|
||||||
|
|
|
@ -23,9 +23,9 @@ if ($is_release | str downcase | str trim) == "y" {
|
||||||
} else {
|
} else {
|
||||||
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
|
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
$"($row_data)(char newline)"
|
$"($row_data)(char newline)"
|
||||||
} | str collect
|
} | str join
|
||||||
} | math avg)
|
} | math avg)
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,9 +43,9 @@ if ($is_release | str downcase | str trim) == "y" {
|
||||||
} else {
|
} else {
|
||||||
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
|
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
$"($row_data)(char cr)"
|
$"($row_data)(char cr)"
|
||||||
} | str collect
|
} | str join
|
||||||
} | math avg)
|
} | math avg)
|
||||||
|
|
||||||
print $"running test 2 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
print $"running test 2 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||||
|
@ -62,9 +62,9 @@ if ($is_release | str downcase | str trim) == "y" {
|
||||||
} else {
|
} else {
|
||||||
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
|
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
$"($row_data)(char cr)"
|
$"($row_data)(char cr)"
|
||||||
} | str collect
|
} | str join
|
||||||
} | math avg)
|
} | math avg)
|
||||||
|
|
||||||
print $"running test 3 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
print $"running test 3 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||||
|
@ -83,9 +83,9 @@ if ($is_release | str downcase | str trim) == "y" {
|
||||||
} else {
|
} else {
|
||||||
$"($ansi1)($fgcolor)m(char sp)($ansi2)"
|
$"($ansi1)($fgcolor)m(char sp)($ansi2)"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
$"($row_data)(char cr)"
|
$"($row_data)(char cr)"
|
||||||
} | str collect
|
} | str join
|
||||||
} | math avg)
|
} | math avg)
|
||||||
|
|
||||||
print $"running test 4 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
print $"running test 4 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||||
|
@ -102,9 +102,9 @@ if ($is_release | str downcase | str trim) == "y" {
|
||||||
} else {
|
} else {
|
||||||
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
|
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
$"($row_data)(char cr)"
|
$"($row_data)(char cr)"
|
||||||
} | str collect
|
} | str join
|
||||||
} | math avg)
|
} | math avg)
|
||||||
|
|
||||||
print $"running test 5 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
print $"running test 5 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||||
|
@ -121,9 +121,9 @@ if ($is_release | str downcase | str trim) == "y" {
|
||||||
} else {
|
} else {
|
||||||
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
|
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
$"($row_data)(char cr)"
|
$"($row_data)(char cr)"
|
||||||
} | str collect
|
} | str join
|
||||||
} | math avg)
|
} | math avg)
|
||||||
|
|
||||||
print $"running test 6 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
print $"running test 6 at (date now | date format '%Y-%m-%d %H:%M:%S.%3f')"
|
||||||
|
@ -140,9 +140,9 @@ if ($is_release | str downcase | str trim) == "y" {
|
||||||
} else {
|
} else {
|
||||||
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
|
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
|
||||||
}
|
}
|
||||||
} | str collect)
|
} | str join)
|
||||||
$"($row_data)(char cr)"
|
$"($row_data)(char cr)"
|
||||||
} | str collect
|
} | str join
|
||||||
} | math avg)
|
} | math avg)
|
||||||
|
|
||||||
print 'collating tests'
|
print 'collating tests'
|
||||||
|
|
|
@ -12,7 +12,7 @@ export def draw [] {
|
||||||
} else {
|
} else {
|
||||||
build-colorstr $r $g $b $col
|
build-colorstr $r $g $b $col
|
||||||
}
|
}
|
||||||
} | str collect
|
} | str join
|
||||||
}
|
}
|
||||||
|
|
||||||
def build-colorstr [
|
def build-colorstr [
|
||||||
|
|
|
@ -47,7 +47,7 @@ def print_run [start:int, amount:int] {
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
} | append " " | str collect
|
} | append " " | str join
|
||||||
}
|
}
|
||||||
|
|
||||||
def print_blocks [start:int, end:int, block_cols:int, block_rows:int, blocks_per_line:int] {
|
def print_blocks [start:int, end:int, block_cols:int, block_rows:int, blocks_per_line:int] {
|
||||||
|
@ -57,9 +57,9 @@ def print_blocks [start:int, end:int, block_cols:int, block_rows:int, blocks_per
|
||||||
0..<$block_rows | each { |row|
|
0..<$block_rows | each { |row|
|
||||||
0..<$blocks_per_line | each { |block|
|
0..<$blocks_per_line | each { |block|
|
||||||
print_run ($start + $block * $block_length + $row * $block_cols + $i * $block_length * $blocks_per_line) $block_cols
|
print_run ($start + $block * $block_length + $row * $block_cols + $i * $block_length * $blocks_per_line) $block_cols
|
||||||
} | append (char nl) | str collect
|
} | append (char nl) | str join
|
||||||
} | str collect
|
} | str join
|
||||||
} | str collect
|
} | str join
|
||||||
}
|
}
|
||||||
|
|
||||||
print (print_run 0 16) # The first 16 colours are spread over the whole spectrum
|
print (print_run 0 16) # The first 16 colours are spread over the whole spectrum
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
# Function querying free online English dictionary API for definition of given word(s)
|
# Function querying free online English dictionary API for definition of given word(s)
|
||||||
def dict [...word #word(s) to query the dictionary API but they have to make sense together like "martial law", not "cats dogs"
|
def dict [...word #word(s) to query the dictionary API but they have to make sense together like "martial law", not "cats dogs"
|
||||||
] {
|
] {
|
||||||
let query = ($word | str collect %20)
|
let query = ($word | str join %20)
|
||||||
let link = ('https://api.dictionaryapi.dev/api/v2/entries/en/' + ($query|str replace ' ' '%20'))
|
let link = ('https://api.dictionaryapi.dev/api/v2/entries/en/' + ($query|str replace ' ' '%20'))
|
||||||
let output = (fetch $link | rename word)
|
let output = (fetch $link | rename word)
|
||||||
let w = ($output.word | first)
|
let w = ($output.word | first)
|
||||||
|
|
||||||
if $w == "No Definitions Found" {
|
if $w == "No Definitions Found" {
|
||||||
echo $output.word
|
echo $output.word
|
||||||
|
|
|
@ -13,7 +13,7 @@ def build-completions-from-pwd [] {
|
||||||
|
|
||||||
# build a completion form a .fish file and generate a .nu file
|
# build a completion form a .fish file and generate a .nu file
|
||||||
def build-completion [fish_file: path, nu_file: path] {
|
def build-completion [fish_file: path, nu_file: path] {
|
||||||
open $fish_file | parse-fish | make-commands-completion | str collect "\n\n" | save $nu_file
|
open $fish_file | parse-fish | make-commands-completion | str join "\n\n" | save $nu_file
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse a .fish file based on autogenerated complete syntax
|
# parse a .fish file based on autogenerated complete syntax
|
||||||
|
@ -97,7 +97,7 @@ def make-subcommands-completion [parents: list] {
|
||||||
build-string (
|
build-string (
|
||||||
if ('d' in ($subcommand.args | columns)) and ($subcommand.args.d != "") {
|
if ('d' in ($subcommand.args | columns)) and ($subcommand.args.d != "") {
|
||||||
build-string "# " ($subcommand.args.d.0) "\n" # (sub)command description
|
build-string "# " ($subcommand.args.d.0) "\n" # (sub)command description
|
||||||
}) "extern " $quote ($parents | str collect " ") (
|
}) "extern " $quote ($parents | str join " ") (
|
||||||
if $subcommand.name != "" {
|
if $subcommand.name != "" {
|
||||||
build-string " " $subcommand.name # sub command if present
|
build-string " " $subcommand.name # sub command if present
|
||||||
}) $quote " [\n" (
|
}) $quote " [\n" (
|
||||||
|
@ -112,7 +112,7 @@ def make-subcommands-completion [parents: list] {
|
||||||
$fishes # catch all
|
$fishes # catch all
|
||||||
}
|
}
|
||||||
| build-flags
|
| build-flags
|
||||||
| str collect "\n"
|
| str join "\n"
|
||||||
) "\n\t...args\n]"
|
) "\n\t...args\n]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ def make-completion [command_name: string] {
|
||||||
}) (if ($it.description | is-empty) == false {
|
}) (if ($it.description | is-empty) == false {
|
||||||
build-string "\t\t# " $it.description
|
build-string "\t\t# " $it.description
|
||||||
})
|
})
|
||||||
} | str collect "\n") "\n\t...args\n]"
|
} | str join "\n") "\n\t...args\n]"
|
||||||
}
|
}
|
||||||
|
|
||||||
module tests {
|
module tests {
|
||||||
|
|
|
@ -33,7 +33,7 @@ def scoopInstalledAppsWithStar [] {
|
||||||
# list of all manifests from all buckets
|
# list of all manifests from all buckets
|
||||||
def scoopAllApps [] {
|
def scoopAllApps [] {
|
||||||
let bucketsDir = if ('SCOOP' in (env).name) { [ (getenv 'SCOOP'), 'buckets' ] | path join } else { [ (getenv 'USERPROFILE'), 'scoop', 'buckets' ] | path join }
|
let bucketsDir = if ('SCOOP' in (env).name) { [ (getenv 'SCOOP'), 'buckets' ] | path join } else { [ (getenv 'USERPROFILE'), 'scoop', 'buckets' ] | path join }
|
||||||
(ls -s $bucketsDir | get name) | each {|bucket| ls ([$bucketsDir, $bucket, 'bucket', '*.json'] | str collect '\') | get name | path basename | str substring ',-5' } | flatten | uniq
|
(ls -s $bucketsDir | get name) | each {|bucket| ls ([$bucketsDir, $bucket, 'bucket', '*.json'] | str join '\') | get name | path basename | str substring ',-5' } | flatten | uniq
|
||||||
}
|
}
|
||||||
|
|
||||||
# list of all apps that are not installed
|
# list of all apps that are not installed
|
||||||
|
|
|
@ -79,7 +79,7 @@ def "winget show" [
|
||||||
(do $flagify header $header)
|
(do $flagify header $header)
|
||||||
(do $flagify accept_source_agreements $accept_source_agreements)
|
(do $flagify accept_source_agreements $accept_source_agreements)
|
||||||
(do $flagify help $help)
|
(do $flagify help $help)
|
||||||
] | str collect ' ')
|
] | str join ' ')
|
||||||
|
|
||||||
if $raw or $help {
|
if $raw or $help {
|
||||||
^$command
|
^$command
|
||||||
|
@ -92,7 +92,7 @@ def "winget show" [
|
||||||
$"(ansi yellow)($output | first | str trim)(ansi reset)"
|
$"(ansi yellow)($output | first | str trim)(ansi reset)"
|
||||||
} else {
|
} else {
|
||||||
let header = ($output | first | parse -r 'Found (?P<Name>.+) \[(?P<Id>.+)\]')
|
let header = ($output | first | parse -r 'Found (?P<Name>.+) \[(?P<Id>.+)\]')
|
||||||
let manifest = ($output | skip 1 | str collect (char newline) | from yaml)
|
let manifest = ($output | skip 1 | str join (char newline) | from yaml)
|
||||||
$header | first | merge { $manifest }
|
$header | first | merge { $manifest }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ def "winget source list" [
|
||||||
$pos_name
|
$pos_name
|
||||||
(do $flagify name $name)
|
(do $flagify name $name)
|
||||||
(do $flagify help $help)
|
(do $flagify help $help)
|
||||||
] | str collect ' ')
|
] | str join ' ')
|
||||||
|
|
||||||
if $raw or $help {
|
if $raw or $help {
|
||||||
^$command
|
^$command
|
||||||
|
@ -200,7 +200,7 @@ def "winget search" [
|
||||||
(do $flagify header $header)
|
(do $flagify header $header)
|
||||||
(do $flagify accept_source_agreements $accept_source_agreements)
|
(do $flagify accept_source_agreements $accept_source_agreements)
|
||||||
(do $flagify help $help)
|
(do $flagify help $help)
|
||||||
] | str collect ' ')
|
] | str join ' ')
|
||||||
|
|
||||||
if $raw or $help {
|
if $raw or $help {
|
||||||
^$command
|
^$command
|
||||||
|
@ -248,7 +248,7 @@ def "winget list" [
|
||||||
(do $flagify header $header)
|
(do $flagify header $header)
|
||||||
(do $flagify accept_source_agreements $accept_source_agreements)
|
(do $flagify accept_source_agreements $accept_source_agreements)
|
||||||
(do $flagify help $help)
|
(do $flagify help $help)
|
||||||
] | str collect ' ')
|
] | str join ' ')
|
||||||
|
|
||||||
if $help or $raw {
|
if $help or $raw {
|
||||||
^$command
|
^$command
|
||||||
|
@ -446,27 +446,27 @@ def "nu-complete winget parse table" [lines: any] {
|
||||||
let version = if $lengths.version > 0 {
|
let version = if $lengths.version > 0 {
|
||||||
(
|
(
|
||||||
$it | skip ($lengths.name + $lengths.id)
|
$it | skip ($lengths.name + $lengths.id)
|
||||||
| first $lengths.version | str collect | str trim
|
| first $lengths.version | str join | str trim
|
||||||
)
|
)
|
||||||
} else { "" }
|
} else { "" }
|
||||||
|
|
||||||
let available = if $lengths.available > 0 {
|
let available = if $lengths.available > 0 {
|
||||||
(
|
(
|
||||||
$it | skip ($lengths.name + $lengths.id + $lengths.version)
|
$it | skip ($lengths.name + $lengths.id + $lengths.version)
|
||||||
| first $lengths.available | str collect | str trim
|
| first $lengths.available | str join | str trim
|
||||||
)
|
)
|
||||||
} else { "" }
|
} else { "" }
|
||||||
|
|
||||||
let source = if $lengths.source > 0 {
|
let source = if $lengths.source > 0 {
|
||||||
(
|
(
|
||||||
$it | skip ($lengths.name + $lengths.id + $lengths.version + $lengths.available)
|
$it | skip ($lengths.name + $lengths.id + $lengths.version + $lengths.available)
|
||||||
| str collect | str trim
|
| str join | str trim
|
||||||
)
|
)
|
||||||
} else { "" }
|
} else { "" }
|
||||||
|
|
||||||
{
|
{
|
||||||
name: ($it | first $lengths.name | str collect | str trim),
|
name: ($it | first $lengths.name | str join | str trim),
|
||||||
id: ($it | skip $lengths.name | first $lengths.id | str collect | str trim),
|
id: ($it | skip $lengths.name | first $lengths.id | str join | str trim),
|
||||||
version: $version,
|
version: $version,
|
||||||
available: $available,
|
available: $available,
|
||||||
source: $source
|
source: $source
|
||||||
|
|
|
@ -15,7 +15,7 @@ export env LS_COLORS {
|
||||||
"mi=00;40;31"
|
"mi=00;40;31"
|
||||||
"ln=00;36"
|
"ln=00;36"
|
||||||
"ex=00;32"
|
"ex=00;32"
|
||||||
] | str collect (char env_sep)
|
] | str join (char env_sep)
|
||||||
}
|
}
|
||||||
export env BROWSER { "firefox" }
|
export env BROWSER { "firefox" }
|
||||||
export env CARGO_TARGET_DIR { "~/.cargo/target" }
|
export env CARGO_TARGET_DIR { "~/.cargo/target" }
|
||||||
|
@ -36,7 +36,7 @@ export def build-prompt [] {
|
||||||
'@'
|
'@'
|
||||||
$env.HOSTNAME
|
$env.HOSTNAME
|
||||||
':'
|
':'
|
||||||
] | str collect
|
] | str join
|
||||||
} else {
|
} else {
|
||||||
''
|
''
|
||||||
})
|
})
|
||||||
|
@ -47,5 +47,5 @@ export def build-prompt [] {
|
||||||
pwd
|
pwd
|
||||||
})
|
})
|
||||||
|
|
||||||
[ $usr_str $pwd_str ' ' ] | str collect
|
[ $usr_str $pwd_str ' ' ] | str join
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ def number-format [
|
||||||
} else {
|
} else {
|
||||||
$whole_part
|
$whole_part
|
||||||
}
|
}
|
||||||
| str collect ''
|
| str join ''
|
||||||
)
|
)
|
||||||
|
|
||||||
let whole_part3 = (
|
let whole_part3 = (
|
||||||
|
|
22
fun/spark.nu
22
fun/spark.nu
|
@ -1,10 +1,10 @@
|
||||||
let TICKS = [(char -u "2581")
|
let TICKS = [(char -u "2581")
|
||||||
(char -u "2582")
|
(char -u "2582")
|
||||||
(char -u "2583")
|
(char -u "2583")
|
||||||
(char -u "2584")
|
(char -u "2584")
|
||||||
(char -u "2585")
|
(char -u "2585")
|
||||||
(char -u "2586")
|
(char -u "2586")
|
||||||
(char -u "2587")
|
(char -u "2587")
|
||||||
(char -u "2588")]
|
(char -u "2588")]
|
||||||
|
|
||||||
# send an array into spark and get a sparkline out
|
# send an array into spark and get a sparkline out
|
||||||
|
@ -20,7 +20,7 @@ def spark [v: list] {
|
||||||
$v | each { |e|
|
$v | each { |e|
|
||||||
let i = ((($e - $min) * $ratio) | math round)
|
let i = ((($e - $min) * $ratio) | math round)
|
||||||
$"($TICKS | get $i)"
|
$"($TICKS | get $i)"
|
||||||
} | str collect
|
} | str join
|
||||||
}
|
}
|
||||||
|
|
||||||
def assert_eq [num: int, expected: string, input: list] {
|
def assert_eq [num: int, expected: string, input: list] {
|
||||||
|
@ -28,10 +28,10 @@ def assert_eq [num: int, expected: string, input: list] {
|
||||||
let span = (metadata $expected).span;
|
let span = (metadata $expected).span;
|
||||||
if $actual != $expected {
|
if $actual != $expected {
|
||||||
error make {
|
error make {
|
||||||
msg: "Actual != Expected",
|
msg: "Actual != Expected",
|
||||||
label: {
|
label: {
|
||||||
text: $"expected ($expected) but got ($actual)", start: $span.start, end: $span.end
|
text: $"expected ($expected) but got ($actual)", start: $span.start, end: $span.end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print $"Test ($num) (ansi green)passed(ansi reset) ✓"
|
print $"Test ($num) (ansi green)passed(ansi reset) ✓"
|
||||||
|
|
|
@ -12,7 +12,7 @@ for $markdown in $markdown_files {
|
||||||
let $header = ($content_lines
|
let $header = ($content_lines
|
||||||
| skip 1
|
| skip 1
|
||||||
| take while {|x| ($x | str trim) != "---"}
|
| take while {|x| ($x | str trim) != "---"}
|
||||||
| str collect "\n"
|
| str join "\n"
|
||||||
| from yaml)
|
| from yaml)
|
||||||
|
|
||||||
let $post = ($content_lines
|
let $post = ($content_lines
|
||||||
|
@ -45,7 +45,7 @@ for $markdown in $markdown_files {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
let $html_post = ($html_post | str collect "\n")
|
let $html_post = ($html_post | str join "\n")
|
||||||
let $html_post = $"<!DOCTYPE html>
|
let $html_post = $"<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|
|
@ -7,7 +7,7 @@ def call-gitlab [
|
||||||
...args: string
|
...args: string
|
||||||
--query: string
|
--query: string
|
||||||
] {
|
] {
|
||||||
fetch -H [Authorization $"Bearer ($env.GITLAB_TOKEN)"] $"($projects)($args|str collect)?($query)"
|
fetch -H [Authorization $"Bearer ($env.GITLAB_TOKEN)"] $"($projects)($args|str join)?($query)"
|
||||||
}
|
}
|
||||||
# Search files on your GitLab server
|
# Search files on your GitLab server
|
||||||
def main [
|
def main [
|
||||||
|
|
|
@ -23,7 +23,7 @@ module hosts {
|
||||||
let WHITELIST = ["multipasko"]
|
let WHITELIST = ["multipasko"]
|
||||||
let BLACKLIST = ["0.0.0.0 tiktok.com"]
|
let BLACKLIST = ["0.0.0.0 tiktok.com"]
|
||||||
|
|
||||||
let whitelisted = "(" + ($WHITELIST | str collect "|") + ")"
|
let whitelisted = "(" + ($WHITELIST | str join "|") + ")"
|
||||||
let pattern = ($"0.0.0.0.*($whitelisted).*$")
|
let pattern = ($"0.0.0.0.*($whitelisted).*$")
|
||||||
let OLD_FILE = "/etc/hosts"
|
let OLD_FILE = "/etc/hosts"
|
||||||
let TMP_FILE = (fetch $LINK | lines)
|
let TMP_FILE = (fetch $LINK | lines)
|
||||||
|
@ -51,13 +51,13 @@ module hosts {
|
||||||
echo "Done!"
|
echo "Done!"
|
||||||
} else {
|
} else {
|
||||||
error make -u {msg: "Something went wrong while overwriting the /etc/hosts file"}
|
error make -u {msg: "Something went wrong while overwriting the /etc/hosts file"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo "No updates available."
|
echo "No updates available."
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error make -u {msg: "Failed downloading the hosts file, try again."}
|
error make -u {msg: "Failed downloading the hosts file, try again."}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ def gen_keywords [] {
|
||||||
and category !~ deprecated
|
and category !~ deprecated
|
||||||
and ($it.command | str contains -n ' ')
|
and ($it.command | str contains -n ' ')
|
||||||
| get command
|
| get command
|
||||||
| str collect '|')
|
| str join '|')
|
||||||
|
|
||||||
let var_with_dash_or_under_regex = '(([a-zA-Z]+[\\-_]){1,}[a-zA-Z]+\\s)'
|
let var_with_dash_or_under_regex = '(([a-zA-Z]+[\\-_]){1,}[a-zA-Z]+\\s)'
|
||||||
let preamble = '\\b('
|
let preamble = '\\b('
|
||||||
|
@ -30,7 +30,7 @@ def gen_sub_keywords [] {
|
||||||
let cmds = (for x in $sub_cmds {
|
let cmds = (for x in $sub_cmds {
|
||||||
let parts = ($x | split row ' ')
|
let parts = ($x | split row ' ')
|
||||||
$'($parts.0)\\s($parts.1)'
|
$'($parts.0)\\s($parts.1)'
|
||||||
} | str collect '|')
|
} | str join '|')
|
||||||
$'"match": "($preamble)($cmds)($postamble)",'
|
$'"match": "($preamble)($cmds)($postamble)",'
|
||||||
}
|
}
|
||||||
$"Generating sub keywords(char nl)"
|
$"Generating sub keywords(char nl)"
|
||||||
|
@ -57,11 +57,11 @@ def gen_keywords_alphabetically [] {
|
||||||
} else {
|
} else {
|
||||||
$nothing
|
$nothing
|
||||||
}
|
}
|
||||||
} | str collect '|')
|
} | str join '|')
|
||||||
if ($letter_cmds | str trim | str length) > 0 {
|
if ($letter_cmds | str trim | str length) > 0 {
|
||||||
$'"match": "($preamble)($letter_cmds)($postamble)",'
|
$'"match": "($preamble)($letter_cmds)($postamble)",'
|
||||||
}
|
}
|
||||||
} | str collect "\n"
|
} | str join "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
"Generating keywords alphabetically\n"
|
"Generating keywords alphabetically\n"
|
||||||
|
@ -89,11 +89,11 @@ def gen_sub_keywords_alphabetically [] {
|
||||||
} else {
|
} else {
|
||||||
$nothing
|
$nothing
|
||||||
}
|
}
|
||||||
} | str collect '|')
|
} | str join '|')
|
||||||
if ($letter_cmds | str trim | str length) > 0 {
|
if ($letter_cmds | str trim | str length) > 0 {
|
||||||
$'"match": "($preamble)($letter_cmds)($postamble)",'
|
$'"match": "($preamble)($letter_cmds)($postamble)",'
|
||||||
}
|
}
|
||||||
} | str collect "\n"
|
} | str join "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
"Generating sub keywords alphabetically\n"
|
"Generating sub keywords alphabetically\n"
|
||||||
|
|
|
@ -132,7 +132,7 @@ export def dec2base [
|
||||||
} else {
|
} else {
|
||||||
let newNumber = (($number - ($number mod $base)) / $base)
|
let newNumber = (($number - ($number mod $base)) / $base)
|
||||||
|
|
||||||
[(dec2base $newNumber $base) ($chars | get ($number mod $base))] | str collect
|
[(dec2base $newNumber $base) ($chars | get ($number mod $base))] | str join
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ def-env which-cd [program] {
|
||||||
def git-push [m: string] {
|
def git-push [m: string] {
|
||||||
git add -A
|
git add -A
|
||||||
git status
|
git status
|
||||||
git commit -am $"($m)"
|
git commit -a -m $"($m)"
|
||||||
git push origin main
|
git push origin main
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ def "help my-commands" [] {
|
||||||
|
|
||||||
#web search in terminal (requires ddgr)
|
#web search in terminal (requires ddgr)
|
||||||
def gg [...search: string] {
|
def gg [...search: string] {
|
||||||
ddgr -n 5 ($search | str collect ' ')
|
ddgr -n 5 ($search | str join ' ')
|
||||||
}
|
}
|
||||||
|
|
||||||
#habitipy dailies done all (requires habitipy)
|
#habitipy dailies done all (requires habitipy)
|
||||||
|
@ -341,7 +341,7 @@ def trans [
|
||||||
let from = if ($from | is-empty) {"en-US"} else {$from}
|
let from = if ($from | is-empty) {"en-US"} else {$from}
|
||||||
let to = if ($to | is-empty) {"es-ES"} else {$to}
|
let to = if ($to | is-empty) {"es-ES"} else {$to}
|
||||||
|
|
||||||
let to_translate = ($search | str collect "%20")
|
let to_translate = ($search | str join "%20")
|
||||||
|
|
||||||
let url = $"https://api.mymemory.translated.net/get?q=($to_translate)&langpair=($from)%7C($to)&of=json&key=($key)&de=($user)"
|
let url = $"https://api.mymemory.translated.net/get?q=($to_translate)&langpair=($from)%7C($to)&of=json&key=($key)&de=($user)"
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ def skim [
|
||||||
let lst = $in
|
let lst = $in
|
||||||
let type = ($lst | describe)
|
let type = ($lst | describe)
|
||||||
let s = (if ($type | str starts-with 'list<') {
|
let s = (if ($type | str starts-with 'list<') {
|
||||||
$lst | str collect (char nl)
|
$lst | str join (char nl)
|
||||||
} else if ($type == 'string') {
|
} else if ($type == 'string') {
|
||||||
$lst
|
$lst
|
||||||
})
|
})
|
||||||
|
|
|
@ -46,7 +46,7 @@ export def ssh [
|
||||||
let host = (hosts|where name == $hostname|get -i 0)
|
let host = (hosts|where name == $hostname|get -i 0)
|
||||||
if ($host.nu) {
|
if ($host.nu) {
|
||||||
if ($args|length) > 0 {
|
if ($args|length) > 0 {
|
||||||
^ssh (get-url $host) (build-string ($args|str collect ' ') '|to json -r')|from json
|
^ssh (get-url $host) (build-string ($args|str join ' ') '|to json -r')|from json
|
||||||
} else {
|
} else {
|
||||||
^ssh (get-url $host)
|
^ssh (get-url $host)
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ export def "ssh script" [
|
||||||
if $script in ($nu.scope.commands|where is_custom|get command) {
|
if $script in ($nu.scope.commands|where is_custom|get command) {
|
||||||
|
|
||||||
let host = (hosts|where name == $hostname|get 0)
|
let host = (hosts|where name == $hostname|get 0)
|
||||||
let full_command = (build-string (view-source $script) '; ' $script ' ' ($args|str collect ' ') '|to json -r')
|
let full_command = (build-string (view-source $script) '; ' $script ' ' ($args|str join ' ') '|to json -r')
|
||||||
^ssh (get-url $host) ($full_command)|from json
|
^ssh (get-url $host) ($full_command)|from json
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -5,7 +5,7 @@ def prompt-concat [parts: table] {
|
||||||
$parts
|
$parts
|
||||||
| where (not ($it.text | is-empty))
|
| where (not ($it.text | is-empty))
|
||||||
| each { |it| $"($it.color)($it.text)" }
|
| each { |it| $"($it.color)($it.text)" }
|
||||||
| str collect ' '
|
| str join ' '
|
||||||
}
|
}
|
||||||
|
|
||||||
def prompt-git-branch [] {
|
def prompt-git-branch [] {
|
||||||
|
|
|
@ -58,7 +58,7 @@ export def path_abbrev_if_needed [apath term_width] {
|
||||||
let tokens = ($tokens | append $"($PB)($splits | last)($R)")
|
let tokens = ($tokens | append $"($PB)($splits | last)($R)")
|
||||||
|
|
||||||
# collect
|
# collect
|
||||||
$tokens | str collect $"($T)/"
|
$tokens | str join $"($T)/"
|
||||||
} else {
|
} else {
|
||||||
if ($splits_len == 0) {
|
if ($splits_len == 0) {
|
||||||
# We're at / on the file system
|
# We're at / on the file system
|
||||||
|
@ -66,7 +66,7 @@ export def path_abbrev_if_needed [apath term_width] {
|
||||||
} else if ($splits_len == 1) {
|
} else if ($splits_len == 1) {
|
||||||
let top_part = ($splits | first)
|
let top_part = ($splits | first)
|
||||||
let tokens = $"($PB)($top_part)($R)"
|
let tokens = $"($PB)($top_part)($R)"
|
||||||
$tokens | str collect $"($T)"
|
$tokens | str join $"($T)"
|
||||||
} else {
|
} else {
|
||||||
let top_part = ($splits | first ($splits_len - 1))
|
let top_part = ($splits | first ($splits_len - 1))
|
||||||
let end_part = ($splits | last)
|
let end_part = ($splits | last)
|
||||||
|
@ -74,7 +74,7 @@ export def path_abbrev_if_needed [apath term_width] {
|
||||||
$"/($T)($x | str substring 0,1)($R)"
|
$"/($T)($x | str substring 0,1)($R)"
|
||||||
})
|
})
|
||||||
let tokens = ($tokens | append $"/($PB)($end_part)($R)")
|
let tokens = ($tokens | append $"/($PB)($end_part)($R)")
|
||||||
$tokens | skip 1 | str collect $"($T)"
|
$tokens | skip 1 | str join $"($T)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ export def get_left_prompt [os use_nerd_fonts] {
|
||||||
$right_transition
|
$right_transition
|
||||||
})
|
})
|
||||||
(char space) # space
|
(char space) # space
|
||||||
] | str collect)
|
] | str join)
|
||||||
|
|
||||||
let is_home_in_path = ($env.PWD | str starts-with $nu.home-path)
|
let is_home_in_path = ($env.PWD | str starts-with $nu.home-path)
|
||||||
let path_segment = (if $is_home_in_path {
|
let path_segment = (if $is_home_in_path {
|
||||||
|
@ -156,7 +156,7 @@ export def get_left_prompt [os use_nerd_fonts] {
|
||||||
$display_path # ~/src/forks/nushell
|
$display_path # ~/src/forks/nushell
|
||||||
(ansi { fg: "#CED7CF" bg: "#3465A4"}) # color just to color the next space
|
(ansi { fg: "#CED7CF" bg: "#3465A4"}) # color just to color the next space
|
||||||
(char space) # space
|
(char space) # space
|
||||||
] | str collect
|
] | str join
|
||||||
} else {
|
} else {
|
||||||
[
|
[
|
||||||
(if $use_nerd_fonts {
|
(if $use_nerd_fonts {
|
||||||
|
@ -168,7 +168,7 @@ export def get_left_prompt [os use_nerd_fonts] {
|
||||||
$display_path # ~/src/forks/nushell
|
$display_path # ~/src/forks/nushell
|
||||||
(ansi { fg: "#CED7CF" bg: "#3465A4"}) # color just to color the next space
|
(ansi { fg: "#CED7CF" bg: "#3465A4"}) # color just to color the next space
|
||||||
(char space) # space
|
(char space) # space
|
||||||
] | str collect
|
] | str join
|
||||||
})
|
})
|
||||||
|
|
||||||
let indicator_segment = (
|
let indicator_segment = (
|
||||||
|
@ -181,7 +181,7 @@ export def get_left_prompt [os use_nerd_fonts] {
|
||||||
" >"
|
" >"
|
||||||
})
|
})
|
||||||
($R) # reset color
|
($R) # reset color
|
||||||
] | str collect
|
] | str join
|
||||||
)
|
)
|
||||||
|
|
||||||
# assemble all segments for final prompt printing
|
# assemble all segments for final prompt printing
|
||||||
|
@ -189,7 +189,7 @@ export def get_left_prompt [os use_nerd_fonts] {
|
||||||
$os_segment
|
$os_segment
|
||||||
$path_segment
|
$path_segment
|
||||||
$indicator_segment
|
$indicator_segment
|
||||||
] | str collect
|
] | str join
|
||||||
}
|
}
|
||||||
|
|
||||||
export def get_right_prompt [os use_nerd_fonts] {
|
export def get_right_prompt [os use_nerd_fonts] {
|
||||||
|
@ -220,7 +220,7 @@ export def get_right_prompt [os use_nerd_fonts] {
|
||||||
(date now | date format '%m/%d/%Y %I:%M:%S%.3f')
|
(date now | date format '%m/%d/%Y %I:%M:%S%.3f')
|
||||||
(char space)
|
(char space)
|
||||||
($R)
|
($R)
|
||||||
] | str collect)
|
] | str join)
|
||||||
|
|
||||||
let time_segment = ([
|
let time_segment = ([
|
||||||
(ansi { fg: $TIME_BG bg: $TERM_FG})
|
(ansi { fg: $TIME_BG bg: $TERM_FG})
|
||||||
|
@ -234,7 +234,7 @@ export def get_right_prompt [os use_nerd_fonts] {
|
||||||
(date now | date format '%I:%M:%S %p')
|
(date now | date format '%I:%M:%S %p')
|
||||||
(char space)
|
(char space)
|
||||||
($R)
|
($R)
|
||||||
] | str collect)
|
] | str join)
|
||||||
|
|
||||||
# 1. datetime - working
|
# 1. datetime - working
|
||||||
# $datetime_segment
|
# $datetime_segment
|
||||||
|
@ -249,7 +249,7 @@ export def get_right_prompt [os use_nerd_fonts] {
|
||||||
# [
|
# [
|
||||||
# $git_segment
|
# $git_segment
|
||||||
# $time_segment
|
# $time_segment
|
||||||
# ] | str collect
|
# ] | str join
|
||||||
|
|
||||||
# 5. fernando wants this on the left prompt
|
# 5. fernando wants this on the left prompt
|
||||||
# [
|
# [
|
||||||
|
|
|
@ -287,7 +287,7 @@ def get_os_segment [os color_mode] {
|
||||||
($transition_bg_color)
|
($transition_bg_color)
|
||||||
($transition_icon)
|
($transition_icon)
|
||||||
(char space)
|
(char space)
|
||||||
] | str collect
|
] | str join
|
||||||
)
|
)
|
||||||
|
|
||||||
$os_segment
|
$os_segment
|
||||||
|
@ -308,7 +308,7 @@ def get_path_segment [os color_mode] {
|
||||||
($pwd_color)
|
($pwd_color)
|
||||||
($pwd_bg_color)
|
($pwd_bg_color)
|
||||||
(char space) # space
|
(char space) # space
|
||||||
] | str collect
|
] | str join
|
||||||
)
|
)
|
||||||
|
|
||||||
$path_segment
|
$path_segment
|
||||||
|
@ -325,7 +325,7 @@ def get_indicator_segment [os color_mode] {
|
||||||
($indicator_bg_color)
|
($indicator_bg_color)
|
||||||
(char nf_segment) #
|
(char nf_segment) #
|
||||||
($R) # reset color
|
($R) # reset color
|
||||||
] | str collect
|
] | str join
|
||||||
)
|
)
|
||||||
|
|
||||||
$indicator_segment
|
$indicator_segment
|
||||||
|
@ -344,7 +344,7 @@ def get_time_segment [os color_mode] {
|
||||||
let R = (ansi reset)
|
let R = (ansi reset)
|
||||||
let time_bg_color = (get_color time_bg_color $color_mode)
|
let time_bg_color = (get_color time_bg_color $color_mode)
|
||||||
let time_color = (get_color time_color $color_mode)
|
let time_color = (get_color time_color $color_mode)
|
||||||
|
|
||||||
let time_segment = ([
|
let time_segment = ([
|
||||||
(ansi { fg: $time_bg_color bg: $time_color})
|
(ansi { fg: $time_bg_color bg: $time_color})
|
||||||
(char nf_right_segment) #(char -u e0b2) #
|
(char nf_right_segment) #(char -u e0b2) #
|
||||||
|
@ -354,7 +354,7 @@ def get_time_segment [os color_mode] {
|
||||||
(date now | date format '%I:%M:%S %p')
|
(date now | date format '%I:%M:%S %p')
|
||||||
(char space)
|
(char space)
|
||||||
($R)
|
($R)
|
||||||
] | str collect)
|
] | str join)
|
||||||
|
|
||||||
$time_segment
|
$time_segment
|
||||||
}
|
}
|
||||||
|
@ -381,7 +381,7 @@ def get_status_segment [os color_mode] {
|
||||||
$env.LAST_EXIT_CODE
|
$env.LAST_EXIT_CODE
|
||||||
(char space)
|
(char space)
|
||||||
($R)
|
($R)
|
||||||
] | str collect
|
] | str join
|
||||||
)
|
)
|
||||||
|
|
||||||
$status_segment
|
$status_segment
|
||||||
|
@ -403,7 +403,7 @@ def get_execution_time_segment [os color_mode] {
|
||||||
$env.CMD_DURATION_MS
|
$env.CMD_DURATION_MS
|
||||||
(char space)
|
(char space)
|
||||||
($R)
|
($R)
|
||||||
] | str collect
|
] | str join
|
||||||
)
|
)
|
||||||
|
|
||||||
$execution_time_segment
|
$execution_time_segment
|
||||||
|
@ -415,7 +415,7 @@ def get_right_prompt [os color_mode] {
|
||||||
let execution_time_segment = (get_execution_time_segment $os $color_mode)
|
let execution_time_segment = (get_execution_time_segment $os $color_mode)
|
||||||
let time_segment = (get_time_segment $os $color_mode)
|
let time_segment = (get_time_segment $os $color_mode)
|
||||||
let exit_if = (if $env.LAST_EXIT_CODE != 0 { $status_segment })
|
let exit_if = (if $env.LAST_EXIT_CODE != 0 { $status_segment })
|
||||||
[$exit_if $execution_time_segment $time_segment] | str collect
|
[$exit_if $execution_time_segment $time_segment] | str join
|
||||||
}
|
}
|
||||||
|
|
||||||
# constructe the left and right prompt by color_mode (8bit or 24bit)
|
# constructe the left and right prompt by color_mode (8bit or 24bit)
|
||||||
|
|
|
@ -4,9 +4,9 @@ def workspaces [] {
|
||||||
if $item.active {
|
if $item.active {
|
||||||
$"(ansi green)($index) "
|
$"(ansi green)($index) "
|
||||||
} else {
|
} else {
|
||||||
$"(ansi blue)($index) "
|
$"(ansi blue)($index) "
|
||||||
}
|
}
|
||||||
}| str collect
|
}| str join
|
||||||
}
|
}
|
||||||
|
|
||||||
def create_right_prompt [] {
|
def create_right_prompt [] {
|
||||||
|
@ -14,7 +14,7 @@ def create_right_prompt [] {
|
||||||
(date now | date format '%r'),
|
(date now | date format '%r'),
|
||||||
" ",
|
" ",
|
||||||
(workspaces)
|
(workspaces)
|
||||||
] | str collect)
|
] | str join)
|
||||||
$time_segment
|
$time_segment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,5 +41,5 @@ def remove-diacritics [
|
||||||
|get -i -s $char
|
|get -i -s $char
|
||||||
|default $char
|
|default $char
|
||||||
}
|
}
|
||||||
|str collect ''
|
|str join ''
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ export def-env auto-venv-on-enter [
|
||||||
)
|
)
|
||||||
|
|
||||||
let venv_path = ([$virtual_env $bin] | path join)
|
let venv_path = ([$virtual_env $bin] | path join)
|
||||||
let new_path = ($old_path | prepend $venv_path | str collect $path_sep)
|
let new_path = ($old_path | prepend $venv_path | str join $path_sep)
|
||||||
|
|
||||||
# Creating the new prompt for the session
|
# Creating the new prompt for the session
|
||||||
let virtual_prompt = if ($virtual_prompt == '') {
|
let virtual_prompt = if ($virtual_prompt == '') {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue