How to enable --message-format=short option globally?

I really like --message-format=short option:

cargo r -r --message-format=short
   Compiling abont-egui v0.0.0 (/home/matklad/p/abont/proto/abont-egui)
abont-egui/src/lib.rs:3:5: warning: unused import: `process::Termination`
abont-egui/src/lib.rs:8:5: warning: unused import: `eframe::glow::COLOR`
abont-egui/src/lib.rs:9:12: warning: unused import: `Color32`
abont-egui/src/lib.rs:18:18: warning: use of deprecated function `std::thread::sleep_ms`: replaced by `std::thread::sleep`
abont-egui/src/lib.rs:29:24: warning: unused variable: `cc`

Is there some way to globally enable it, so that this is the default format for rustc messages on my machine?

1 Like

You could add an alias in your Cargo config file ~/.cargo/config

https://doc.rust-lang.org/cargo/reference/config.html

[alias]
r = "run -r --message-format=short"

and then from the command line:

cargo r
1 Like

Might be worth filing a feature request (couldn't find one) for a CARGO_MESSAGE_FORMAT environment variable and/or a configuration option under [term] (which'd be the two most obvious places to put global configuration of the message format IMO).

If you do file an issue for this and the Cargo devs are in favour of it, please share a link here, I'd be interested in implementing this :smile:

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.