mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-10-05 17:48:11 +03:00
Replace use of $nothing
with null
(#621)
`$nothing` will be deprecated in nu 0.86 This accompanies - https://github.com/nushell/nushell/pull/10478
This commit is contained in:
parent
9ceac61989
commit
6947014306
@ -16,5 +16,5 @@ seq 0 $height | par-each {|| # create these in parallel
|
||||
}
|
||||
} | str join)
|
||||
print -n $"($row_data)" | table
|
||||
$nothing
|
||||
null
|
||||
} | compact
|
||||
|
@ -27,7 +27,7 @@ def parse-fish [] {
|
||||
| flatten # merge them all into a top level label
|
||||
)
|
||||
# default every column in the table to "" to make processing easier
|
||||
# some values having $nothing often breaks nu or requires lots of checking
|
||||
# some values having null often breaks nu or requires lots of checking
|
||||
$data | columns | reduce -f $data { |c, acc|
|
||||
$acc | default "" $c
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ def "nu-complete winget source type" [] {
|
||||
|
||||
def "nu-complete winget flagify" [name: string, value: any, --short(-s): bool] {
|
||||
let flag_start = if $short { '-' } else { '--' }
|
||||
if $value == $nothing or $value == false {
|
||||
if $value == null or $value == false {
|
||||
""
|
||||
} else if $value == true {
|
||||
$"($flag_start)($name)"
|
||||
|
@ -23,7 +23,7 @@ export-env {
|
||||
$env.config = ( $env.config | upsert hooks.env_change.PWD { |config|
|
||||
let o = ($config | get -i hooks.env_change.PWD)
|
||||
let val = (direnv)
|
||||
if $o == $nothing {
|
||||
if $o == null {
|
||||
$val
|
||||
} else {
|
||||
$o | append $val
|
||||
|
@ -11,7 +11,7 @@ export-env {
|
||||
$env.config = ( $env.config | upsert hooks.env_change.PWD { |config|
|
||||
let o = ($config | get -i hooks.env_change.PWD)
|
||||
let val = (dynamic_load)
|
||||
if $o == $nothing {
|
||||
if $o == null {
|
||||
$val
|
||||
} else {
|
||||
$o | append $val
|
||||
|
@ -21,7 +21,7 @@ def-env j [dir] {
|
||||
$env.config = ($env.config | upsert hooks.env_change.PWD {|config|
|
||||
let val = ($config | get -i hooks.env_change.PWD)
|
||||
|
||||
if $val == $nothing {
|
||||
if $val == null {
|
||||
$val | append {|before, after| autojump_add_to_database $after }
|
||||
} else {
|
||||
[
|
||||
|
@ -55,7 +55,7 @@ def gen_keywords_alphabetically [] {
|
||||
if ($cmd | str starts-with $alpha) {
|
||||
$cmd
|
||||
} else {
|
||||
$nothing
|
||||
null
|
||||
}
|
||||
} | str join '|')
|
||||
if ($letter_cmds | str trim | str length) > 0 {
|
||||
@ -87,7 +87,7 @@ def gen_sub_keywords_alphabetically [] {
|
||||
let parts = ($cmd | split row ' ')
|
||||
$'($parts.0)\\s($parts.1)'
|
||||
} else {
|
||||
$nothing
|
||||
null
|
||||
}
|
||||
} | str join '|')
|
||||
if ($letter_cmds | str trim | str length) > 0 {
|
||||
|
@ -43,7 +43,7 @@ export-env {
|
||||
$env.config = ( $env.config | upsert hooks.env_change.PWD { |config|
|
||||
let o = ($config | get -i hooks.env_change.PWD)
|
||||
let val = (nvim_tcd)
|
||||
if $o == $nothing {
|
||||
if $o == null {
|
||||
$val
|
||||
} else {
|
||||
$o | append $val
|
||||
|
@ -23,7 +23,7 @@ def prompt-create-left-prompt [] {
|
||||
}
|
||||
|
||||
def prompt-create-right-prompt [] {
|
||||
$nothing
|
||||
null
|
||||
}
|
||||
|
||||
$env.PROMPT_COMMAND = { prompt-create-left-prompt }
|
||||
|
@ -260,7 +260,7 @@ export def get_right_prompt [os use_nerd_fonts] {
|
||||
}
|
||||
|
||||
export def get_prompt [nerd?] {
|
||||
let use_nerd_fonts = ($nerd != $nothing)
|
||||
let use_nerd_fonts = ($nerd != null)
|
||||
let os = ((sys).host.name)
|
||||
let left_prompt = (get_left_prompt $os $use_nerd_fonts)
|
||||
let right_prompt = (get_right_prompt $os $use_nerd_fonts)
|
||||
|
@ -168,12 +168,12 @@ let runtime_colors = [
|
||||
{ name: prompt_color_separator_same_color, '8bit': $prompt_color_separator_same_color_8, '24bit': $prompt_color_separator_same_color_24 },
|
||||
{ name: left_separator_diff_color, '8bit': $left_prompt_separator_diff_color, '24bit': $left_prompt_separator_diff_color },
|
||||
{ name: left_separator_same_color, '8bit': $left_prompt_separator_same_color, '24bit': $left_prompt_separator_same_color },
|
||||
{ name: left_prefix, value: $nothing },
|
||||
{ name: left_suffix, value: $nothing },
|
||||
{ name: left_prefix, value: null },
|
||||
{ name: left_suffix, value: null },
|
||||
{ name: right_separator_diff_color, '8bit': $right_prompt_separator_diff_color, '24bit': $right_prompt_separator_diff_color },
|
||||
{ name: right_separator_same_color, '8bit': $right_prompt_separator_same_color, '24bit': $right_prompt_separator_same_color },
|
||||
{ name: right_prefix, value: $nothing },
|
||||
{ name: right_suffix, value: $nothing },
|
||||
{ name: right_prefix, value: null },
|
||||
{ name: right_suffix, value: null },
|
||||
|
||||
{ name: cmd_bg_color, '8bit': $cmd_duration_bg_color_8, '24bit': $cmd_duration_bg_color_24 },
|
||||
{ name: cmd_color, '8bit': $cmd_duration_color_8, '24bit': $cmd_duration_color_24 },
|
||||
@ -199,9 +199,9 @@ let runtime_colors = [
|
||||
{ name: pwd_color_anchors, '8bit': $pwd_color_anchors_8, '24bit': $pwd_color_anchors_24 },
|
||||
{ name: pwd_color_dirs, '8bit': $pwd_color_dirs_8, '24bit': $pwd_color_dirs_24 },
|
||||
{ name: pwd_color_truncated_dirs, '8bit': $pwd_color_truncated_dirs_8, '24bit': $pwd_color_truncated_dirs_24 },
|
||||
{ name: pwd_icon, value: $nothing },
|
||||
{ name: pwd_icon_home, value: $nothing },
|
||||
{ name: pwd_icon_unwritable, value: $nothing },
|
||||
{ name: pwd_icon, value: null },
|
||||
{ name: pwd_icon_home, value: null },
|
||||
{ name: pwd_icon_unwritable, value: null },
|
||||
|
||||
{ name: rustc_bg_color, '8bit': $rustc_bg_color_8, '24bit': $rustc_bg_color_24 },
|
||||
{ name: rustc_color, '8bit': $rustc_color_8, '24bit': $rustc_color_24 },
|
||||
@ -211,12 +211,12 @@ let runtime_colors = [
|
||||
{ name: status_bg_color_failure, '8bit': $status_bg_color_failure_8, '24bit': $status_bg_color_failure_24 },
|
||||
{ name: status_color, '8bit': $status_color_8, '24bit': $status_color_24 },
|
||||
{ name: status_color_failure, '8bit': $status_color_failure_8 , '24bit': $status_color_failure_24 },
|
||||
{ name: status_icon, value: $nothing },
|
||||
{ name: status_icon_failure, value: $nothing },
|
||||
{ name: status_icon, value: null },
|
||||
{ name: status_icon_failure, value: null },
|
||||
|
||||
{ name: time_bg_color, '8bit': $time_bg_color_8, '24bit': $time_bg_color_24 },
|
||||
{ name: time_color, '8bit': $time_color_8, '24bit': $time_color_24 },
|
||||
{ name: time_format, value: $nothing },
|
||||
{ name: time_format, value: null },
|
||||
|
||||
{ name: indicator_bg_color, '8bit': $indicator_bg_color_8, '24bit': $indicator_bg_color_24 },
|
||||
{ name: indicator_color, '8bit': $indicator_color_8, '24bit': $indicator_color_24 },
|
||||
|
@ -12,7 +12,7 @@ use power.nu
|
||||
}
|
||||
use power_utils.nu
|
||||
power inject 0 1 {source: atuin, color: '#4C4B4A'}
|
||||
power set time $nothing { short: false }
|
||||
power set time null { short: false }
|
||||
power init
|
||||
```
|
||||
or
|
||||
@ -60,7 +60,7 @@ power analyze
|
||||
```
|
||||
|
||||
## todo
|
||||
- [x] source return `$nothing` for hiding
|
||||
- [x] source return `null` for hiding
|
||||
- [ ] in fast mode, there is still a problem with hideable components on the left
|
||||
- [x] proxy stat invalid in plain mode
|
||||
- '<<' not longer hide separator in `fast` mode
|
||||
|
@ -55,7 +55,7 @@ export def proxy_stat [] {
|
||||
if not (($env.https_proxy? | is-empty) and ($env.http_proxy? | is-empty)) {
|
||||
[$bg '']
|
||||
} else {
|
||||
[$bg $nothing]
|
||||
[$bg null]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -192,7 +192,7 @@ def left_prompt [segment] {
|
||||
let segment = ($segment
|
||||
| reduce -f [] {|x, acc|
|
||||
let y = (do $x.1 $x.0)
|
||||
if $y.1 == $nothing {
|
||||
if $y.1 == null {
|
||||
$acc
|
||||
} else {
|
||||
$acc | append [$y]
|
||||
@ -226,7 +226,7 @@ def right_prompt [segment] {
|
||||
$segment
|
||||
| reduce -f [] {|x,acc|
|
||||
let y = (do $x.1 $x.0)
|
||||
if $y.1 == $nothing {
|
||||
if $y.1 == null {
|
||||
$acc
|
||||
} else {
|
||||
$acc | append [$y]
|
||||
@ -292,8 +292,8 @@ def decorator_gen [
|
||||
def squash [thunk] {
|
||||
mut r = ""
|
||||
for t in $thunk {
|
||||
let v = (do $t.0 $nothing)
|
||||
if ($v.1 != $nothing) {
|
||||
let v = (do $t.0 null)
|
||||
if ($v.1 != null) {
|
||||
$r += (do $t.1 $v.1)
|
||||
}
|
||||
}
|
||||
@ -342,8 +342,8 @@ def up_prompt [segment] {
|
||||
| each {|y|
|
||||
$y
|
||||
| reduce -f [] {|x, acc|
|
||||
let y = (do $x $nothing)
|
||||
if $y.1 == $nothing {
|
||||
let y = (do $x null)
|
||||
if $y.1 == null {
|
||||
$acc
|
||||
} else {
|
||||
$acc | append $y.1
|
||||
|
@ -20,7 +20,7 @@ def "kube ctx" [] {
|
||||
$cache = $"($env.HOME)/.cache/nu-power/kube-($env.KUBECONFIG | str replace -a '/' ':').json"
|
||||
$file = $env.KUBECONFIG
|
||||
}
|
||||
if not ($file | path exists) { return $nothing }
|
||||
if not ($file | path exists) { return null }
|
||||
ensure-cache $cache $file {
|
||||
do -i {
|
||||
kubectl config get-contexts
|
||||
|
@ -19,7 +19,7 @@ export-env {
|
||||
|
||||
|
||||
def default-hooks [] {
|
||||
(if ($env.config.hooks.env_change.PWD != $nothing) {
|
||||
(if ($env.config.hooks.env_change.PWD != null) {
|
||||
[$env.config.hooks.env_change.PWD]
|
||||
}
|
||||
else {
|
||||
|
@ -29,7 +29,7 @@ export def "path check-sub" [
|
||||
|
||||
(ls -a $folder
|
||||
| where (
|
||||
($type == $nothing or $it.type in $type)
|
||||
($type == null or $it.type in $type)
|
||||
and ($it.name | path basename) == $subfolder
|
||||
)
|
||||
| length
|
||||
@ -53,7 +53,7 @@ export def "path find-sub" [
|
||||
)
|
||||
);
|
||||
|
||||
if ($paths != $nothing) and ($paths | length) > 0 {
|
||||
if ($paths != null) and ($paths | length) > 0 {
|
||||
[ ($paths | first), $subfolder ] | path join
|
||||
} else {[]}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ export def-env activate [
|
||||
PROMPT_COMMAND: $new_prompt
|
||||
}
|
||||
} else {
|
||||
$new_env | merge { CONDA_OLD_PROMPT_COMMAND: $nothing }
|
||||
$new_env | merge { CONDA_OLD_PROMPT_COMMAND: null }
|
||||
}
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ export def-env deactivate [] {
|
||||
hide-env CONDA_OLD_PATH
|
||||
|
||||
$env.PROMPT_COMMAND = (
|
||||
if $env.CONDA_OLD_PROMPT_COMMAND == $nothing {
|
||||
if $env.CONDA_OLD_PROMPT_COMMAND == null {
|
||||
$env.PROMPT_COMMAND
|
||||
} else {
|
||||
$env.CONDA_OLD_PROMPT_COMMAND
|
||||
|
@ -167,8 +167,8 @@ export def get_weather [
|
||||
] {
|
||||
let token = "85a4e3c55b73909f42c6a23ec35b7147"
|
||||
|
||||
let is_loc_empty = ($locIdx == $nothing)
|
||||
let is_units_empty = ($units == $nothing)
|
||||
let is_loc_empty = ($locIdx == null)
|
||||
let is_units_empty = ($units == null)
|
||||
|
||||
let no_loc_no_unit = ($is_loc_empty == true and $is_units_empty == true)
|
||||
let no_loc_with_unit = ($is_loc_empty == true and $is_units_empty == false)
|
||||
|
@ -39,8 +39,8 @@ def get_flag [
|
||||
--test_int(-i): int # The test intlocation
|
||||
--test_string(-s): string # The test string
|
||||
] {
|
||||
let is_int_empty = ($test_int == $nothing)
|
||||
let is_string_empty = ($test_string == $nothing)
|
||||
let is_int_empty = ($test_int == null)
|
||||
let is_string_empty = ($test_string == null)
|
||||
|
||||
let no_int_no_string = ($is_int_empty == true and $is_string_empty == true)
|
||||
let no_int_with_string = ($is_int_empty == true and $is_string_empty == false)
|
||||
|
Loading…
Reference in New Issue
Block a user