mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-02 07:07:46 +00:00
update prompts scripts with new str replace
syntax (#579)
This commit is contained in:
parent
dd499c916f
commit
8e086d8771
5 changed files with 13 additions and 13 deletions
|
@ -64,13 +64,13 @@ def dir_string [] {
|
||||||
}
|
}
|
||||||
|
|
||||||
let dir = ([
|
let dir = ([
|
||||||
($env.PWD | str substring 0..($home | str length) | str replace --string $home "~"),
|
($env.PWD | str substring 0..($home | str length) | str replace $home "~"),
|
||||||
($env.PWD | str substring ($home | str length)..)
|
($env.PWD | str substring ($home | str length)..)
|
||||||
] | str join)
|
] | str join)
|
||||||
|
|
||||||
let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold })
|
let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold })
|
||||||
let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold })
|
let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold })
|
||||||
$"($path_color)($dir)(ansi reset)" | str replace --all --string (char path_sep) $"($separator_color)/($path_color)"
|
$"($path_color)($dir)(ansi reset)" | str replace --all (char path_sep) $"($separator_color)/($path_color)"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Following code cheerfully ~~stolen~~ adapted from:
|
# Following code cheerfully ~~stolen~~ adapted from:
|
||||||
|
|
|
@ -20,14 +20,14 @@ def home_abbrev [os] {
|
||||||
let is_home_in_path = ($env.PWD | str starts-with $nu.home-path)
|
let is_home_in_path = ($env.PWD | str starts-with $nu.home-path)
|
||||||
if ($is_home_in_path == true) {
|
if ($is_home_in_path == true) {
|
||||||
if ($os == "Windows") {
|
if ($os == "Windows") {
|
||||||
let home = ($nu.home-path | str replace -a '\\' '/')
|
let home = ($nu.home-path | str replace -ar '\\' '/')
|
||||||
let pwd = ($env.PWD | str replace -a '\\' '/')
|
let pwd = ($env.PWD | str replace -ar '\\' '/')
|
||||||
$pwd | str replace $home '~'
|
$pwd | str replace $home '~'
|
||||||
} else {
|
} else {
|
||||||
$env.PWD | str replace $nu.home-path '~'
|
$env.PWD | str replace $nu.home-path '~'
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$env.PWD | str replace -a '\\' '/'
|
$env.PWD | str replace -ar '\\' '/'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,14 +240,14 @@ def home_abbrev [os_name] {
|
||||||
let is_home_in_path = ($env.PWD | str starts-with $nu.home-path)
|
let is_home_in_path = ($env.PWD | str starts-with $nu.home-path)
|
||||||
if $is_home_in_path {
|
if $is_home_in_path {
|
||||||
if ($os_name == "windows") {
|
if ($os_name == "windows") {
|
||||||
let home = ($nu.home-path | str replace -a '\\' '/')
|
let home = ($nu.home-path | str replace -ar '\\' '/')
|
||||||
let pwd = ($env.PWD | str replace -a '\\' '/')
|
let pwd = ($env.PWD | str replace -ar '\\' '/')
|
||||||
$pwd | str replace $home '~'
|
$pwd | str replace $home '~'
|
||||||
} else {
|
} else {
|
||||||
$env.PWD | str replace $nu.home-path '~'
|
$env.PWD | str replace $nu.home-path '~'
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$env.PWD | str replace -a '\\' '/'
|
$env.PWD | str replace -ar '\\' '/'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ def home_abbrev [os_name] {
|
||||||
let is_home_in_path = ($env.PWD | str starts-with $nu.home-path)
|
let is_home_in_path = ($env.PWD | str starts-with $nu.home-path)
|
||||||
if $is_home_in_path {
|
if $is_home_in_path {
|
||||||
if ($os_name =~ "windows") {
|
if ($os_name =~ "windows") {
|
||||||
let home = ($nu.home-path | str replace -a '\\' '/')
|
let home = ($nu.home-path | str replace -ar '\\' '/')
|
||||||
let pwd = ($env.PWD | str replace -a '\\' '/')
|
let pwd = ($env.PWD | str replace -ar '\\' '/')
|
||||||
$pwd | str replace $home '~'
|
$pwd | str replace $home '~'
|
||||||
} else {
|
} else {
|
||||||
$env.PWD | str replace $nu.home-path '~'
|
$env.PWD | str replace $nu.home-path '~'
|
||||||
|
@ -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 -ar '\\' '/' | str substring 2..
|
||||||
} else {
|
} else {
|
||||||
$env.PWD
|
$env.PWD
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,9 @@ export def current-dir [] {
|
||||||
let in_sub_dir_of_home = ($current_dir_relative_to_home | is-empty | nope)
|
let in_sub_dir_of_home = ($current_dir_relative_to_home | is-empty | nope)
|
||||||
|
|
||||||
let current_dir_abbreviated = (if $in_sub_dir_of_home {
|
let current_dir_abbreviated = (if $in_sub_dir_of_home {
|
||||||
$'~(char separator)($current_dir_relative_to_home)' | str replace -a '\\' '/'
|
$'~(char separator)($current_dir_relative_to_home)' | str replace -ar '\\' '/'
|
||||||
} else {
|
} else {
|
||||||
$current_dir | str replace -a '\\' '/'
|
$current_dir | str replace -ar '\\' '/'
|
||||||
})
|
})
|
||||||
|
|
||||||
$'(ansi reset)($current_dir_abbreviated)'
|
$'(ansi reset)($current_dir_abbreviated)'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue