blob: 70bc0937a8a81a0e17f8361e4be77cb2de57c3ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#
# Rust
#
# Rust is a systems programming language sponsored by Mozilla Research.
# Link: https://www.rust-lang.org
# ------------------------------------------------------------------------------
# Configuration
# ------------------------------------------------------------------------------
SPACESHIP_RUST_SHOW="${SPACESHIP_RUST_SHOW=true}"
SPACESHIP_RUST_PREFIX="${SPACESHIP_RUST_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_RUST_SUFFIX="${SPACESHIP_RUST_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_RUST_SYMBOL="${SPACESHIP_RUST_SYMBOL="🦀 "}"
SPACESHIP_RUST_COLOR="${SPACESHIP_RUST_COLOR="red"}"
SPACESHIP_RUST_VERBOSE_VERSION="${SPACESHIP_RUST_VERBOSE_VERSION=false}"
# ------------------------------------------------------------------------------
# Section
# ------------------------------------------------------------------------------
# Show current version of Rust
spaceship_rust() {
[[ $SPACESHIP_RUST_SHOW == false ]] && return
# If there are Rust-specific files in current directory
[[ -f Cargo.toml || -n *.rs(#qN^/) ]] || return
spaceship::exists rustc || return
local rust_version=$(rustc --version | cut -d' ' -f2)
if [[ $SPACESHIP_RUST_VERBOSE_VERSION == false ]]; then
local rust_version=$(echo $rust_version | cut -d'-' -f1) # Cut off -suffixes from version. "v1.30.0-beta.11" or "v1.30.0-nightly"
fi
spaceship::section \
"$SPACESHIP_RUST_COLOR" \
"$SPACESHIP_RUST_PREFIX" \
"${SPACESHIP_RUST_SYMBOL}v${rust_version}" \
"$SPACESHIP_RUST_SUFFIX"
}
|