1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-02 15:17:47 +00:00

update range syntax in str substring usage (#448)

This commit is contained in:
Darren Schroeder 2023-04-16 07:15:37 -05:00 committed by GitHub
parent 2d12532495
commit 87655ab380
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 7 deletions

View file

@ -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 join '\') | 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

View file

@ -9,7 +9,7 @@ def main [
] { ] {
cargo llvm-cov show-env --export-prefix | cargo llvm-cov show-env --export-prefix |
lines | lines |
str substring '7,' | str substring 7.. |
split column '=' | split column '=' |
str trim -c '"' | str trim -c '"' |
transpose | transpose |

View file

@ -54,7 +54,7 @@ export-env {
def edit [action file] { def edit [action file] {
if 'NVIM' in ($env | columns) { if 'NVIM' in ($env | columns) {
let af = ($file | each {|f| let af = ($file | each {|f|
if ($f|str substring ',1') in ['/', '~'] { if ($f|str substring ..1) in ['/', '~'] {
$f $f
} else { } else {
$"($env.PWD)/($f)" $"($env.PWD)/($f)"

View file

@ -51,7 +51,7 @@ export def path_abbrev_if_needed [apath term_width] {
if (($apath | str length) > ($term_width / 2)) { if (($apath | str length) > ($term_width / 2)) {
# get all the tokens except the last # get all the tokens except the last
let tokens = ($splits | take ($splits_len - 1) | each {|x| let tokens = ($splits | take ($splits_len - 1) | each {|x|
$"($T)($x | str substring 0,1)($R)" $"($T)($x | str substring 0..1)($R)"
}) })
# append the last part of the path # append the last part of the path
@ -71,7 +71,7 @@ export def path_abbrev_if_needed [apath term_width] {
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)
let tokens = ($top_part | each {|x| let tokens = ($top_part | each {|x|
$"/($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 join $"($T)" $tokens | skip 1 | str join $"($T)"

View file

@ -26,7 +26,7 @@ def home_abbrev [os_name] {
} else { } else {
if ($os_name =~ "windows") { if ($os_name =~ "windows") {
# remove the C: from the path # remove the C: from the path
$env.PWD | str replace -a '\\' '/' | str substring '2,' $env.PWD | str replace -a '\\' '/' | str substring 2..
} else { } else {
$env.PWD $env.PWD
} }

View file

@ -77,7 +77,7 @@ export def repo-structured [] {
| split column ' ' col1 col2 full_hash | split column ' ' col1 col2 full_hash
| get full_hash | get full_hash
| first | first
| str substring [0 7] | str substring 0..7
} else { } else {
'' ''
}) })