summaryrefslogtreecommitdiff
path: root/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/rust.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/rust.zsh')
-rw-r--r--dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/rust.zsh42
1 files changed, 42 insertions, 0 deletions
diff --git a/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/rust.zsh b/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/rust.zsh
new file mode 100644
index 00000000..70bc0937
--- /dev/null
+++ b/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/rust.zsh
@@ -0,0 +1,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"
+}