Closed Aloxaf closed 4 years ago
Rustup will change ~/.rustup/settings.toml
when I change the default rust toolchain version.
Here is its content on my system:
default_toolchain = "nightly-x86_64-unknown-linux-gnu"
version = "12"
[overrides]
And if I update the toolchain, ~/.rustup/update-hashes/nightly-x86_64-unknown-linux-gnu
will be updated:
❯ cat ~/.rustup/update-hashes/nightly-x86_64-unknown-linux-gnu
74e88a41126c2cfb904b
Maybe should check whether a user is using rustup or just a rustc installed by the system package manager, then use different way to get the version?
Thanks for the bug report and super valuable insights. I'm on it.
I added support for rustup
. All types of toolchain overrides should work:
export RUSTUP_TOOLCHAIN=nightly
rustup override set nightly
echo nightly >rust-toolchain
In all cases p10k shows the same rust version as rustc --version
.
The implementation is a bit slower than I'd like (about 0.6 ms on my machine) but it'll do for now. I'll get back to it when I consolidate stat calls for parent directories.
I also added P9K_RUST_VERSION
. Like other P9K_*
parameters, this one is set by p10k (users of p10k set POWERLEVEL9K_*
parameters). It contains the full output of rustc --version
and you can use it in POWERLEVEL9K_RUST_VERSION_CONTENT_EXPANSION
. For example:
typeset -g POWERLEVEL9K_RUST_VERSION_CONTENT_EXPANSION='${P9K_RUST_VERSION#rustc }'
If you've never used *_CONTENT_EXPANSION
before, it overrides the content of a prompt segment. The original content is available in $P9K_CONTENT
so that you can patch it if desired. You can use percent escapes there, too.
# The same as the default but bold and bracketed.
typeset -g POWERLEVEL9K_RUST_VERSION_CONTENT_EXPANSION='%B[$P9K_CONTENT]%b'
Let me know if this works for you.
Thanks for your quick fix! POWERLEVEL9K_RUST_VERSION_CONTENT_EXPANSION
is awesome!
There is still a small bug:
https://github.com/romkatv/powerlevel10k/blob/1cf99b34e550e0294cb5d300bbf5b4eb331687aa/internal/p10k.zsh#L2374
Here $rustc
will be expanded to rustup
, so $rustc --version
will only get rustup version. Change it to rustc --version
then everything works. ( just a personal try, not sure if it can be a real solutoin
Fixed.
FWIW, my installation of rustup uses hard links. This makes sense. Using symlinks and together with dispatch by argv[0]
is crazy. Perhaps they've fixed it?
Thanks for reporting the issue and for testing my fixes!
By the way, before you invest into heavy customization of ~/p10k.zsh
, consider switching to Lean style.
It works, thanks for your great work!
I installed rustup by the system package manager. Maybe this is an OS-specific problem? (My OS is Arch Linux)
Thanks for your advice. I'm just new to p10k and is exploring it.
Thanks for your advice. I'm just new to p10k and is exploring it.
Welcome aboard! If you feel like trying bleeding edge (but very cool!) features, check out https://github.com/romkatv/powerlevel10k/issues/318. Maybe this could be useful for rust, too? For example, you could configure p10k to display rust version only when your current command (the one you are still typing) invokes rustc
. Or perhaps display it if there is Cargo.toml
in one of the parent directories OR the current command is rustc
? Basically, if you can come up with cool ideas of what prompt should do, I can implement them. I'm hardly using any of the technologies that p10k users use, so I rely on others to educate me.
still doesn't work
@debian-user-france1 If something doesn't work for you, please open an issue.
This seems to have been fixed in #365. But it only works if the rustc is installed by the system package manager. If I use rustup to manage different versions of rust toolchains, it won't work.
Here is some information:
BTW. I suggest (adding an option?) showing the date of the nightly version, because many projects depend on a specific nightly version, like remacs, tikv. It will be helpful If I can confirm whether I am using the right version from PROMPT info.