Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add operating system module #4109

Merged
merged 36 commits into from Nov 6, 2022
Merged

Conversation

exincore
Copy link
Contributor

@exincore exincore commented Jun 23, 2022

Description

The os module shows the current operating system.
OS information is detected via the os_info crate.

Disabled by default due to os_info inaccuracies for the time being.

NOTE: os_info v3.5.0 should have much improved detection, but this remains to be confirmed

Motivation and Context

Inspired by os_icon 'segment' of romkatv/powerlevel10k

Fixes #4292

Screenshots:

image
image
image

How Has This Been Tested?

  • I have tested using MacOS
  • I have tested using Linux
  • I have tested using Windows

Checklist:

  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.

@exincore exincore marked this pull request as ready for review June 24, 2022 23:48
@andytom
Copy link
Member

andytom commented Jun 26, 2022

I have only had a quick look but think we need to think about the default configuration here we are moving away from using nerd fonts (see #3544). However happy to see this module happening we seem to get a lot of questions/requests for this feature.

@exincore
Copy link
Contributor Author

Ah, well I have exactly what you request (probably)! I spent a good few hours coming up with a reasonable list of emojis that represent the operating systems instead of nerd font. I have yet to finalize my edits to the Presets themselves, but you can see the emoji list is implemented as one of the modules/os.rs tests

@exincore
Copy link
Contributor Author

exincore commented Jun 27, 2022

I'm not quite sure how to handle updates to the os_info crate adding new os_info::Type enum options. Perhaps a comment on the crate in cargo.toml to caution that if new options were added, new default symbols should be created, tests updated, config schema updated, etc...?

docs/config/README.md Outdated Show resolved Hide resolved
docs/config/README.md Show resolved Hide resolved
docs/config/README.md Outdated Show resolved Hide resolved
src/configs/os.rs Outdated Show resolved Hide resolved
@davidkna
Copy link
Member

davidkna commented Jul 5, 2022

I'm not quite sure how to handle updates to the os_info crate adding new os_info::Type enum options. Perhaps a comment on the crate in cargo.toml to caution that if new options were added, new default symbols should be created, tests updated, config schema updated, etc...?

I think a comment is fine, most popular os-types are already covered. Maybe a macro can handle detecting this?

src/modules/os.rs Outdated Show resolved Hide resolved
@exincore
Copy link
Contributor Author

exincore commented Jul 6, 2022

Docs may be typeset weirdly; I don't think this is terribly important though.
image

@exincore
Copy link
Contributor Author

exincore commented Nov 2, 2022

@davidkna I think the CI tests screwed up? Could you run them again?

Copy link
Member

@andytom andytom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andytom andytom merged commit 3109943 into starship:master Nov 6, 2022
@andytom
Copy link
Member

andytom commented Nov 6, 2022

Thank you for your contribution @exincore and thank you for reviewing @davidkna.

@fadeevab
Copy link

@andytom @exincore It's inspiring that Nerd fonts have actual logos for OSes:
image

There are Windows and Apple logs too.

What about to utilize them instead of standard emojis? You already use Nerd-specific symbols for Rust and NodeJS and other.

Here is how I trick the shell module:
image

Although, I find pretty convenient to use specific brand icons for cmd and powershell while using Ubuntu symbol for bash.

image

From this point of view, it would be cool to introduce an $os variable to the shell module to use OS as an icon for some shells.

@exincore
Copy link
Contributor Author

@fadeevab The list of Nerd Font operating system symbols is provided within the preset "Nerd Font Symbols"; one may copy the [os.symbols] section into one's own starship.toml. Starship is moving towards emoji as default, so that Nerd Font is not a default requirement; see #3544 .

As for implementing os in the shell module, that will likely not happen. I actually use both the os and shell module side by side to get a quick glance at what commands I can expect to use on a particular system.

image

In this case, Fedora with Fish.

@fadeevab
Copy link

fadeevab commented Nov 19, 2022

@exincore Gotcha. If you don't mind, I have a question: now, the shell module's default symbols are actual words like bsh, fsh, etc. Is there a chance to make emoji/nerd icons by default in the shell module, so it would look similarly to what on your screenshot? It would be more consistent to overall ideology and design (we have a Nerd icon for Rust, not rst word, don't we).

UPD: Just used your way using both shell and os modules, it looks neat.

@exincore
Copy link
Contributor Author

exincore commented Dec 8, 2022

@fadeevab I apologize for the delay. I would suggest bringing these topics up in the Starship discord server. I am merely a lowly contributor and I do not manage design decisions.

Indyandie pushed a commit to Indyandie/starship that referenced this pull request Jul 26, 2023
* docs(os): Add os module documentation

* docs(os): Add os to Default Prompt Format

* chore(os): Update config file schema

* feat(os): Add os entries and declarations

* feat(os): Add os module and config

* fix(os): Obey config.disabled

* feat(os): make variables 'Unknown'-aware

refactor(os): calculate variables in dedicated functions

* test(os): Add os module tests

* feat(os): make 'name' variable less 'Unknown'-aware

* docs(os): Add Preset configurations

docs(os): Use emoji as default

* feat(os): Use emoji as default

test(os): Use emoji as default

* fix(os): Add spaces after emoji symbols

* chore(os): Update config schema

* feat(os): Remove `bitness` variable

docs(os): Remove `bitness` variable

test(os): Remove `bitness` test

* feat(os): Add Cargo.toml upgrade caution for os_info

* refactor(os): Clarify get_symbol function

* docs(os): Mention supported operating systems and feature requests

* docs(os): Mention os_info inacurracy

* test(os): Remove `bitness` leftovers

* refactor(os): use nu_ansi_term

* refactor(os): add cfg_attr(schemars(deny_unknown_fields))

* chore(os): update config schema

* docs(os): expose details block

* feat(os): add garuda linux

* chore(os): update config schema

* feat(os): add case insensitivity

* feat(os): add symbols `IndexMap` use `os_info::Type` instead of `String`

* test(os): add clippy warn on new os_info::Type case

* leave missing case to test github tests

* test(os): re-add missing test case

* style(os): fix formatting

* docs(os): update to match os_info::Type serialization

- docs(os): add missing garuda to config

- test(os): mention docs updates in warn_on_os_info_update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Module for retrieving the Operating System / Kernel
4 participants