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,16 +41,19 @@ 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)"
|
||||||
})
|
})
|
||||||
|
|
||||||
# need an insert command
|
# need an insert command
|
||||||
let tokens = ($tokens | prepend $"($T)~")
|
let tokens = ($tokens | prepend $"($T)~")
|
||||||
|
|
||||||
# append the last part of the path
|
# append the last part of the path
|
||||||
let tokens = ($tokens | append $"($PB)($splits | last | get 0)($R)")
|
let tokens = ($tokens | append $"($PB)($splits | last | 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)) {
|
||||||
|
@ -72,14 +75,18 @@ def path_abbrev_if_needed [apath term_width] {
|
||||||
|
|
||||||
# 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.
|
||||||
# cd "/Applications/Hex Fiend.app/"
|
# cd "/Applications/Hex Fiend.app/"
|
||||||
# ~/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)
|
||||||
|
@ -205,9 +212,9 @@ def git_prompt [] {
|
||||||
let conflicted_cnt = (get_conflicted_count $gs)
|
let conflicted_cnt = (get_conflicted_count $gs)
|
||||||
let untracked_cnt = (get_untracked_count $gs)
|
let untracked_cnt = (get_untracked_count $gs)
|
||||||
let has_no_changes = (
|
let has_no_changes = (
|
||||||
if ($index_change_cnt <= 0) &&
|
if ($index_change_cnt <= 0) &&
|
||||||
($wt_change_cnt <= 0) &&
|
($wt_change_cnt <= 0) &&
|
||||||
($conflicted_cnt <= 0) &&
|
($conflicted_cnt <= 0) &&
|
||||||
($untracked_cnt <= 0) {
|
($untracked_cnt <= 0) {
|
||||||
$true
|
$true
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue