Fixed prompt_rust_version to avoid grep aliases #826
Conversation
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.
Thanks @TheDan64 for this PR.
powerlevel9k.zsh-theme
Outdated
@@ -1104,10 +1104,14 @@ prompt_root_indicator() { | |||
# Print Rust version number | |||
prompt_rust_version() { | |||
local rust_version | |||
rust_version=$(rustc --version 2>&1 | grep -oe "^rustc\s*[^ ]*" | grep -o '[0-9.a-z\\\-]*$') | |||
rust_version=$(command rustc --version 2>&1) |
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 raises an error, if rustc is not installed. We should silence all errors here:
rust_version=$(command rustc --version 2>/dev/null)
|
||
if [[ -n "$rust_version" ]]; then | ||
"$1_prompt_segment" "$0" "$2" "208" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON' | ||
"$1_prompt_segment" "$0" "$2" "208" "$DEFAULT_COLOR" "$rust_version" 'RUST_ICON' |
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.
Thanks for the review; I silenced the missing rustc error and tried to fix the test. Any idea what's going on with the last broken test? |
Hah. 🤦♂️ In our test we mock |
Fix test for rust segment
Just for the record: This PR is related to #632 |
Conflicts were: - test/segments/rust_version.spec and powerlevel9k.zsh-theme. Powerlevel9k#826 removes grep from parsing the rust version on next; Powerlevel9k#703 changes color names.
Fixes #803