Current toolchain name for PS1 prompt
- Dominant language
- Shell
- Stars
- 651
- Forks
- 35
- PR merge metrics
- No merged PRs in 30d
Description
I like to include profile information in my bash shell prompt about the current directory/project (eg, current git branch, rbenv ruby version, etc.). I would like to be able to indicate which multirust toolchain is currently active in a succinct fashion (eg, "nightly", "stable").
Currently, the only way to determine which toolchain would be run is to parse output from `multirust show-override`:
```
$ multirust show-override
multirust: override toolchain: nightly
multirust: override location: /Users/aetherkn/.multirust/toolchains/nightly
multirust: override reason: directory override for '/Users/aetherkn/src/rust/games-for-redox'
rustc 1.9.0-nightly (b12b4e4e3 2016-03-17)
cargo 0.10.0-nightly (ece4e96 2016-03-17)
```
I'm currently parsing it with something like:
``` bash
__rust_version() {
test -r Cargo.toml || return # Detect a Rust project
type -p multirust > /dev/null || return
local v=""
local overrideinfo=$(multirust show-override)
local firstline=$(echo "${overrideinfo}" | head -n1)
if [[ "$firstline" =~ "override toolchain:" ]] ; then
v=${firstline#*override toolchain: }
else
local secondline=$(echo "${overrideinfo}" | head -n2 | tail -n1)
v=${secondline#*default toolchain: }
fi
if [ ! -z "$v" ] ; then
echo "|⚙ ${v}"
fi
}
```
However, this could be greatly simplified (and would be less brittle to changes in multirust's output) if multirust provided a sub-command or a flag to compute the the current toolchain name. It could also avoid calling rustc and cargo to get their versions. It could simplify to something like:
``` bash
__rust_version() {
test -r Cargo.toml || return # Detect a Rust project
type -p multirust > /dev/null || return
local v=$(multirust show-toolchain)
if [ ! -z "$v" ] ; then
echo "|⚙ ${v}"
fi
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.