Skip to content

Commit

Permalink
Add option to toggle verbose rust version (spaceship-prompt#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
Snuggle authored and salmanulfarzy committed Nov 21, 2018
1 parent 8b0e0d7 commit 6792870
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ Rust section is shown only in directories that contain `Cargo.toml` or any other
| `SPACESHIP_RUST_SUFFIX` | `$SPACESHIP_PROMPT_DEFAULT_SUFFIX` | Suffix after the Rust section |
| `SPACESHIP_RUST_SYMBOL` | `𝗥·` | Character to be shown before Rust version |
| `SPACESHIP_RUST_COLOR` | `red` | Color of Rust section |
| `SPACESHIP_RUST_VERBOSE_VERSION` | `false` | Show what branch is being used, if any. (Beta, Nightly) |

### Haskell (`haskell`)

Expand Down
5 changes: 5 additions & 0 deletions sections/rust.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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
Expand All @@ -29,6 +30,10 @@ spaceship_rust() {

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" \
Expand Down

0 comments on commit 6792870

Please sign in to comment.