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

Fixed sys usage (#916)

Just as a heads up, I haven't really tested this since a lot of it is
stuff I don't use or know how to set up without some reading up. I have
tested the nu_conda_2 change since I have a python project that I use
that for, and I could look into testing more of it if needed.

I've tried finding (naively using `/sys\W/`) all the usage of the old
plain `sys` calls and replacing them with alternates as appropriate,
which mostly has been to swap a `(sys).host.name` call into a
`$nu.os-info.name` one, since it'll be tad faster and more consistent
across platforms with naming (especially as the value comes from the
[rust stdlib](https://doc.rust-lang.org/std/env/consts/constant.OS.html)
and is very predictable).

Fixes #897
This commit is contained in:
Elizabeth 2024-07-24 15:09:31 +01:00 committed by GitHub
parent 3b39ef75c9
commit eedcd10dbb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 18 additions and 25 deletions

View file

@ -19,7 +19,7 @@
def home_abbrev [os] {
let is_home_in_path = ($env.PWD | str starts-with $nu.home-path)
if ($is_home_in_path == true) {
if ($os == "Windows") {
if ($os == "windows") {
let home = ($nu.home-path | str replace -ar '\\' '/')
let pwd = ($env.PWD | str replace -ar '\\' '/')
$pwd | str replace $home '~'
@ -82,21 +82,21 @@ export def path_abbrev_if_needed [apath term_width] {
def get_os_icon [os use_nerd_fonts] {
# f17c = tux, f179 = apple, f17a = windows
if $use_nerd_fonts {
if ($os =~ Darwin) {
if ($os =~ macos) {
(char -u f179)
} else if ($os =~ Linux) {
} else if ($os =~ linux) {
(char -u f17c)
} else if ($os =~ Windows) {
} else if ($os =~ windows) {
(char -u f17a)
} else {
''
}
} else {
if ($os =~ Darwin) {
if ($os =~ macos) {
"M"
} else if ($os =~ Linux) {
} else if ($os =~ linux) {
"L"
} else if ($os =~ Windows) {
} else if ($os =~ windows) {
"W"
} else {
''
@ -261,7 +261,7 @@ export def get_right_prompt [os use_nerd_fonts] {
export def get_prompt [nerd?] {
let use_nerd_fonts = ($nerd != null)
let os = ((sys).host.name)
let os = $nu.os-info.name
let left_prompt = (get_left_prompt $os $use_nerd_fonts)
let right_prompt = (get_right_prompt $os $use_nerd_fonts)