mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
Merge pull request #31 from fdncred/main
updated count with length following changes in 0.28.0 nushell
This commit is contained in:
commit
26bc224129
3 changed files with 13 additions and 13 deletions
|
@ -5,16 +5,16 @@ def duplicates [
|
|||
] {
|
||||
group-by $column |
|
||||
pivot |
|
||||
insert count { = $it.Column1 | flatten | count} |
|
||||
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
|
||||
}
|
||||
|
||||
# duplicates files recursively finds duplicate files in the current working folder.
|
||||
# It uses a heuristic based on duplicate files having the same size.
|
||||
# duplicates files recursively finds duplicate files in the current working folder.
|
||||
# It uses a heuristic based on duplicate files having the same size.
|
||||
def "duplicates files" [] {
|
||||
do -i {ls **/*} | duplicates size
|
||||
}
|
||||
|
|
|
@ -82,11 +82,11 @@ def set_title_str [str-arg] {
|
|||
echo [$(ansi title) ' ' $str-arg ' ' $(char bel)] | str collect
|
||||
}
|
||||
def get_abbrev_pwd_win [] {
|
||||
echo [$(pwd | split row '\' | first $(pwd | split row '\' | count | each {= $it - 1} ) | str substring '0,1' | format '{$it}/' | append $(pwd | split row '\' | last ) | str collect)] | str collect
|
||||
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 '/' | count | 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 '/' | count | 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)
|
||||
|
|
|
@ -5,7 +5,7 @@ def print [
|
|||
...rest # All of the parameters
|
||||
] {
|
||||
let is_empty = $(= $separator | empty?)
|
||||
let num_of_rest = $(echo $rest | count)
|
||||
let num_of_rest = $(echo $rest | length)
|
||||
echo $rest | each --numbered {
|
||||
if $is_empty {
|
||||
build-string $it.item
|
||||
|
@ -33,7 +33,7 @@ def print2 [
|
|||
...rest # All of the parameters
|
||||
] {
|
||||
let is_empty = $(= $separator | empty?)
|
||||
let num_of_rest = $(echo $rest | count)
|
||||
let num_of_rest = $(echo $rest | length)
|
||||
if $is_empty {
|
||||
echo $rest | str from | str collect
|
||||
} {
|
||||
|
@ -53,12 +53,12 @@ def print3 [
|
|||
...rest # All of the parameters
|
||||
] {
|
||||
let sep_empty = $(= $separator | empty?)
|
||||
let num_of_rest = $(echo $rest | count)
|
||||
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 | count) > 1 && $flat {
|
||||
if $(echo $it.item | length) > 1 && $flat {
|
||||
#log 'flatten please'
|
||||
let flatter = $(echo $it.item | flatten | str from | str collect)
|
||||
build-string $flatter
|
||||
|
@ -68,14 +68,14 @@ def print3 [
|
|||
}
|
||||
} {
|
||||
if $num_of_rest > $(= $it.index + 1) {
|
||||
if $(echo $it.item | count) > 1 && $flat {
|
||||
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 | count) > 1 && $flat {
|
||||
if $(echo $it.item | length) > 1 && $flat {
|
||||
let flatter = $(echo $it.item | flatten | str from | str collect $separator)
|
||||
build-string $flatter
|
||||
} {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue