forked from extern/nushell
Compress $HOME into ~ in prompt (#8173)
This commit is contained in:
parent
0e86ba4b63
commit
aba0fb0000
@ -1,10 +1,16 @@
|
|||||||
# Nushell Environment Config File
|
# Nushell Environment Config File
|
||||||
|
|
||||||
def create_left_prompt [] {
|
def create_left_prompt [] {
|
||||||
|
let home = ($env | get -i (if $nu.os-info.name == "windows" { "USERPROFILE" } else { "HOME" }) | into string)
|
||||||
|
let dir = ([
|
||||||
|
($env.PWD | str substring 0..($home | str length) | str replace -s $home "~"),
|
||||||
|
($env.PWD | str substring ($home | str length)..)
|
||||||
|
] | str join)
|
||||||
|
|
||||||
let path_segment = if (is-admin) {
|
let path_segment = if (is-admin) {
|
||||||
$"(ansi red_bold)($env.PWD)"
|
$"(ansi red_bold)($dir)"
|
||||||
} else {
|
} else {
|
||||||
$"(ansi green_bold)($env.PWD)"
|
$"(ansi green_bold)($dir)"
|
||||||
}
|
}
|
||||||
|
|
||||||
$path_segment
|
$path_segment
|
||||||
|
Loading…
Reference in New Issue
Block a user