46 lines
1.6 KiB
Bash
46 lines
1.6 KiB
Bash
|
#
|
||
|
# Swift
|
||
|
#
|
||
|
# A general-purpose, multi-paradigm, compiled programming language by Apple Inc.
|
||
|
# Link: https://developer.apple.com/swift/
|
||
|
|
||
|
# ------------------------------------------------------------------------------
|
||
|
# Configuration
|
||
|
# ------------------------------------------------------------------------------
|
||
|
|
||
|
SPACESHIP_SWIFT_ASYNC="${SPACESHIP_SWIFT_ASYNC=true}"
|
||
|
SPACESHIP_SWIFT_SHOW_LOCAL="${SPACESHIP_SWIFT_SHOW_LOCAL=true}"
|
||
|
SPACESHIP_SWIFT_SHOW_GLOBAL="${SPACESHIP_SWIFT_SHOW_GLOBAL=false}"
|
||
|
SPACESHIP_SWIFT_PREFIX="${SPACESHIP_SWIFT_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
|
||
|
SPACESHIP_SWIFT_SUFFIX="${SPACESHIP_SWIFT_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
|
||
|
SPACESHIP_SWIFT_SYMBOL="${SPACESHIP_SWIFT_SYMBOL="🐦 "}"
|
||
|
SPACESHIP_SWIFT_COLOR="${SPACESHIP_SWIFT_COLOR="yellow"}"
|
||
|
|
||
|
# ------------------------------------------------------------------------------
|
||
|
# Section
|
||
|
# ------------------------------------------------------------------------------
|
||
|
|
||
|
# Show current version of Swift
|
||
|
spaceship_swift() {
|
||
|
spaceship::exists swiftenv || return
|
||
|
|
||
|
local swift_version
|
||
|
|
||
|
if [[ $SPACESHIP_SWIFT_SHOW_GLOBAL == true ]] ; then
|
||
|
swift_version=$(swiftenv version | sed 's/ .*//')
|
||
|
elif [[ $SPACESHIP_SWIFT_SHOW_LOCAL == true ]] ; then
|
||
|
if swiftenv version | grep ".swift-version" > /dev/null; then
|
||
|
swift_version=$(swiftenv version | sed 's/ .*//')
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
[ -n "${swift_version}" ] || return
|
||
|
|
||
|
spaceship::section \
|
||
|
--color "$SPACESHIP_SWIFT_COLOR" \
|
||
|
--prefix "$SPACESHIP_SWIFT_PREFIX" \
|
||
|
--suffix "$SPACESHIP_SWIFT_SUFFIX" \
|
||
|
--symbol "$SPACESHIP_SWIFT_SYMBOL" \
|
||
|
"$swift_version"
|
||
|
}
|