-
Notifications
You must be signed in to change notification settings - Fork 227
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
Add a rustc version segment with multiple install options #314
base: master
Are you sure you want to change the base?
Conversation
@bobthecow This is ready to review when you want, and has been rebased on laster master branch. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How expensive are cargo lookups? Can we default to on if rustc is present?
functions/fish_prompt.fish
Outdated
case yes | ||
cargo locate-project --message-format plain --quiet >/dev/null 2>/dev/null | ||
and set local_rustc_version (__bobthefish_get_cargo_version (__bobthefish_pwd)) | ||
case diff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the default behavior for most segments (e.g. ruby). Can we make two options, always and yes, and have yes do what diff currently does?
(Alternatively, if it's not to expensive to default on, it would be off/always).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It takes 70msec to run rustc --version
. I think it's too much to run with every prompt; if you had 2-3 of these it would be a third of a second and it's noticeable. But I'll defer the final decision to you.
I've done the first part.
functions/fish_prompt.fish
Outdated
@@ -846,6 +847,47 @@ function __bobthefish_prompt_rubies -S -d 'Display current Ruby information' | |||
echo -ns $ruby_glyph $ruby_version ' ' | |||
end | |||
|
|||
function __bobthefish_get_cargo_version -S -d 'Display the cargo version in a directory' | |||
pushd $argv[1] | |||
command rustc --version | cut -d ' ' -f 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does rustc take a working directory to save us from a pushd/popd? Otherwise, we should probably add command
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately no. I'll add command
but I'm also exploring if there's a better way to get this information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I decided to rely on fish -c " ... "
to create a subshell only if we need to (which should be once for the global anyway).
PTAL. |
Ping, @bobthecow |
@bobthecow Ping. I have additional changes that I would like to submit a PR for, but they're based on this and don't want to pollute your queue. |
This adds 4 options for rustc (if installed):
always
will always show the version.yes
will show the version of rustc if we can locate the Cargo.toml file (usingcargo locate-project
).diff
will show the version if there's a different result than the global rustc (as ran in the root). This is useful when using.rust-toolchain
files to enforce specific version of the toolchain, for example.