mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-02 07:07:46 +00:00
updates to help with windows parsing
This commit is contained in:
parent
babb4b5a0c
commit
e6da4bb77e
1 changed files with 19 additions and 12 deletions
|
@ -27,7 +27,7 @@ def home_abbrev [os] {
|
||||||
$nu.cwd | str find-replace $nu.home-path '~'
|
$nu.cwd | str find-replace $nu.home-path '~'
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$nu.cwd
|
$nu.cwd | str find-replace -a '\\' '/'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,10 +41,13 @@ def path_abbrev_if_needed [apath term_width] {
|
||||||
|
|
||||||
if (($apath | str length) > ($term_width / 2)) {
|
if (($apath | str length) > ($term_width / 2)) {
|
||||||
# split out by path separator into tokens
|
# split out by path separator into tokens
|
||||||
let splits = ($apath | split row (char psep))
|
# don't use psep here because in home_abbrev we're making them all '/'
|
||||||
|
let splits = ($apath | split row '/')
|
||||||
|
|
||||||
|
let splits_len = ($splits | length)
|
||||||
|
let subtractor = (if ($splits_len <= 2) { 1 } else { 2 })
|
||||||
# get all the tokens except the last
|
# get all the tokens except the last
|
||||||
let tokens = (for x in 1..(($splits | length) - 2) {
|
let tokens = (for x in 1..($splits_len - $subtractor) {
|
||||||
$"($T)((($splits) | get $x | split chars) | get 0)($R)"
|
$"($T)((($splits) | get $x | split chars) | get 0)($R)"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -60,7 +63,7 @@ def path_abbrev_if_needed [apath term_width] {
|
||||||
# $"($P)($apath)($R)"
|
# $"($P)($apath)($R)"
|
||||||
|
|
||||||
# FIXME: This is close but it fails with folder with space. I'm not sure why.
|
# FIXME: This is close but it fails with folder with space. I'm not sure why.
|
||||||
# let splits = ($apath | split row (char psep))
|
# let splits = ($apath | split row '/')
|
||||||
# let splits_len = ($splits | length)
|
# let splits_len = ($splits | length)
|
||||||
# let tokens = (for x in 0..($splits_len - 1) {
|
# let tokens = (for x in 0..($splits_len - 1) {
|
||||||
# if ($x < ($splits_len - 1)) {
|
# if ($x < ($splits_len - 1)) {
|
||||||
|
@ -75,11 +78,15 @@ def path_abbrev_if_needed [apath term_width] {
|
||||||
# ~/H/A/Hex Fiend.app
|
# ~/H/A/Hex Fiend.app
|
||||||
# should be
|
# should be
|
||||||
# ~/A/Hex Fiend.app
|
# ~/A/Hex Fiend.app
|
||||||
let splits = ($apath | split row (char psep))
|
let splits = ($apath | split row '/')
|
||||||
let splits_len = ($splits | length)
|
let splits_len = ($splits | length)
|
||||||
if ($splits_len == 0) {
|
if ($splits_len == 0) {
|
||||||
# We're at / on the file system
|
# We're at / on the file system
|
||||||
$"/($T)"
|
$"/($T)"
|
||||||
|
} else if ($splits_len == 1) {
|
||||||
|
let top_part = ($splits | first)
|
||||||
|
let tokens = $"($PB)($top_part)($R)"
|
||||||
|
$tokens | str collect $"($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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue