diff --git a/modules/argx/argx.nu b/modules/argx/argx.nu index c43cf1fb..41da4ba1 100644 --- a/modules/argx/argx.nu +++ b/modules/argx/argx.nu @@ -7,10 +7,10 @@ export def get-sign [cmd] { mut r = [] for it in $x { if $it.parameter_type == 'switch' { - if not ($it.short_flag | is-empty) { + if ($it.short_flag | is-not-empty) { $s ++= $it.short_flag } - if not ($it.parameter_name | is-empty) { + if ($it.parameter_name | is-not-empty) { $s ++= $it.parameter_name } } else if $it.parameter_type == 'named' { diff --git a/modules/docker/docker.nu b/modules/docker/docker.nu index 823c3507..cde112ce 100644 --- a/modules/docker/docker.nu +++ b/modules/docker/docker.nu @@ -1,6 +1,6 @@ export-env { for c in [nerdctl podman docker] { - if not (which $c | is-empty) { + if (which $c | is-not-empty) { $env.docker-cli = $c break } @@ -195,7 +195,7 @@ def "nu-complete docker cp" [cmd: string, offset: int] { | each {|x| $"($n | get 0):($x)"} } else { let files = do -i { - ls -a $"($p)*" + ls -a ($"($p)*" | into glob) | each {|x| if $x.type == dir { $"($x.name)/"} else { $x.name }} } $files | append $ctn @@ -396,7 +396,7 @@ export def container-create [ } def has [name] { - $name in ($in | columns) and (not ($in | get $name | is-empty)) + $name in ($in | columns) and ($in | get $name | is-not-empty) } def "nu-complete registry show" [cmd: string, offset: int] { @@ -461,7 +461,7 @@ export def "docker registry delete" [ | str trim } print -e $digest - if not ($digest | is-empty) { + if ($digest | is-not-empty) { curl -sSL -X DELETE ...$header $"($url)/v2/($reg)/manifests/($digest)" } else { 'not found' diff --git a/modules/git/git-v2.nu b/modules/git/git-v2.nu index 441c0b35..c4bae663 100644 --- a/modules/git/git-v2.nu +++ b/modules/git/git-v2.nu @@ -77,12 +77,24 @@ export def gb [ ] { let bs = git branch | lines | each {|x| $x | str substring 2..} if ($branch | is-empty) { - let d = { - local: (git branch | lines) - remote: (git branch --remote | lines) - no-merged: (git branch --no-merged | lines) + let no_merged = git branch --no-merged | lines | str trim + { + local: (git branch) + remote: (git branch --remote) } - print ($d | table -i 1 -e) + | transpose k v + | each {|x| + $x.v | lines + | each {|n| + let n = $n | parse -r '\s*(?P\*)?\s*(?P[^\s]+)( -> )?(?P[^\s]+)?' | get 0 + let c = if ($n.c | is-empty) { null } else { true } + let r = if ($n.r | is-empty) { null } else { $n.r } + let nm = if $n.b in $no_merged { true } else { null } + let rm = if $x.k == 'remote' { true } else { null } + { current: $c, remote: $rm, branch: $n.b, ref: $r, no-merged: $nm } + } + } + | flatten } else if $delete { if $branch in $bs and (agree 'branch will be delete!') { git branch -D $branch @@ -318,7 +330,7 @@ export def gr [ git rebase --skip } else if $quit { git rebase --quit - } else if not ($onto | is-empty) { + } else if ($onto | is-not-empty) { git rebase --onto $branch } else { let i = if $interactive {[--interactive]} else {[]} diff --git a/modules/kubernetes/kubernetes.nu b/modules/kubernetes/kubernetes.nu index 727de45c..a583ac99 100644 --- a/modules/kubernetes/kubernetes.nu +++ b/modules/kubernetes/kubernetes.nu @@ -4,7 +4,7 @@ export def ensure-cache-by-lines [cache path action] { let ls = do -i { open $path | lines | length } if ($ls | is-empty) { return false } let lc = do -i { open $cache | get lines} - if not (($cache | path exists) and (not ($lc | is-empty)) and ($ls == $lc)) { + if not (($cache | path exists) and ($lc | is-not-empty) and ($ls == $lc)) { mkdir ($cache | path dirname) { lines: $ls @@ -298,7 +298,7 @@ def "nu-complete kube jsonpath" [context: string] { let m = kubectl get ...$ns $kind $res $"--output=jsonpath={($p)}" | from json let l = $row | last let c = do -i {$m | get $l} - if (not ($c | is-empty)) and ($c | describe | str substring 0..5) == 'table' { + if ($c | is-not-empty) and ($c | describe | str substring 0..5) == 'table' { $r = (0..(($c | length) - 1) | each {|x| $'($p).($l)[($x)]'}) } else { $r = ($m | columns | each {|x| $'($p).($x)'}) @@ -463,7 +463,7 @@ export def kgp [ --selector (-l): string --all (-a) ] { - if not ($r | is-empty) { + if ($r | is-not-empty) { kubectl get pods ...($namespace | with-flag -n) $r --output=json | from json | {...$in.metadata, ...$in.spec, ...$in.status} @@ -612,7 +612,7 @@ def "nu-complete kube cp" [cmd: string, offset: int] { | lines | each {|x| $"($n | get 0):($x)"} } else { - let files = do -i { ls -a $"($p)*" + let files = do -i { ls -a ($"($p)*" | into glob) | each {|x| if $x.type == dir { $"($x.name)/"} else { $x.name }} } $files | append $ctn @@ -951,18 +951,18 @@ export def kcmp [--without-service(-s)] { | each {|z| let sp = $z.subPath? | default '' let s = $v | get $z.name - let s = if not ($s.hostPath? | is-empty) { + let s = if ($s.hostPath? | is-not-empty) { $s.hostPath.path - } else if not ($s.path? | is-empty) { + } else if ($s.path? | is-not-empty) { $s.path - } else if not ($s.persistentVolumeClaim?.claimName? | is-empty) { + } else if ($s.persistentVolumeClaim?.claimName? | is-not-empty) { $pvc | get $s.persistentVolumeClaim.claimName - } else if not ($s.configMap?.name? | is-empty) { + } else if ($s.configMap?.name? | is-not-empty) { ['.' ($cm | get $s.configMap.name) $sp ] | path join - } else if not ($s.secret?.secretName? | is-empty) { + } else if ($s.secret?.secretName? | is-not-empty) { ['.' ($sec | get $s.secret.secretName) $sp @@ -1059,7 +1059,7 @@ def "nu-complete helm charts" [context: string, offset: int] { let ctx = $context | argx parse let path = $ctx | get _pos.chart let path = if ($path | is-empty) { '.' } else { $path } - let paths = do -i { ls $"($path)*" | each {|x| if $x.type == dir { $"($x.name)/"} else { $x.name }} } + let paths = do -i { ls ($"($path)*" | into glob) | each {|x| if $x.type == dir { $"($x.name)/"} else { $x.name }} } helm repo list | from ssv -a | rename value description | append $paths } diff --git a/modules/network/ssh.nu b/modules/network/ssh.nu index b17537ea..6a8863a6 100644 --- a/modules/network/ssh.nu +++ b/modules/network/ssh.nu @@ -1,8 +1,8 @@ export def ensure-cache [cache paths action] { mut cfgs = [] for i in $paths { - let cs = (do -i {ls $i}) - if not ($cs | is-empty) { + let cs = (do -i {ls ($i | into glob)}) + if ($cs | is-not-empty) { $cfgs = ($cfgs | append $cs) } } @@ -120,7 +120,7 @@ def "nu-complete scp" [cmd: string, offset: int] { | each {|x| $"($n | get 0):($x)"} } else { let files = (do -i { - ls -a $"($p)*" + ls -a ($"($p)*" | into glob) | each {|x| if $x.type == dir { $"($x.name)/"} else { $x.name }} }) $files | append $ssh diff --git a/modules/nvim/nvim.nu b/modules/nvim/nvim.nu index aa7234cf..9f83b0bd 100644 --- a/modules/nvim/nvim.nu +++ b/modules/nvim/nvim.nu @@ -32,7 +32,7 @@ def nvim_tcd [] { [ {|before, after| - if not ($env.NVIM? | is-empty) { + if ($env.NVIM? | is-not-empty) { nvim --headless --noplugin --server $env.NVIM --remote-send $"lua HookPwdChanged\('($after)', '($before)')" } } @@ -122,7 +122,7 @@ export def nvc [ neovide: [--maximized --server $addr] } for g in ($gs | transpose prog args) { - if not (which $g.prog | is-empty) { + if (which $g.prog | is-not-empty) { ^$g.prog ...$g.args break }