Merge pull request #347 from thomaspaulmann/swift

Add prompt for current installed swift version
pull/22/head
Ben Hilburn 8 years ago committed by GitHub
commit 7a49c9704d

@ -123,6 +123,8 @@ The segments that are currently available are:
* [`rspec_stats`](#rspec_stats) - Show a ratio of test classes vs code classes for RSpec. * [`rspec_stats`](#rspec_stats) - Show a ratio of test classes vs code classes for RSpec.
* **Rust Segments:** * **Rust Segments:**
* `rust_version` - Display the current rust version and [logo](https://www.rust-lang.org/logos/rust-logo-blk.svg). * `rust_version` - Display the current rust version and [logo](https://www.rust-lang.org/logos/rust-logo-blk.svg).
* **Swift Segments:**
* `swift_version` - Show the version number of the installed Swift.
**Cloud Segments:** **Cloud Segments:**
* **AWS Segments:** * **AWS Segments:**

@ -72,6 +72,7 @@ case $POWERLEVEL9K_MODE in
VCS_SVN_ICON '(svn) ' VCS_SVN_ICON '(svn) '
RUST_ICON '' RUST_ICON ''
PYTHON_ICON $'\U1F40D' # 🐍 PYTHON_ICON $'\U1F40D' # 🐍
SWIFT_ICON ''
) )
;; ;;
'awesome-fontconfig') 'awesome-fontconfig')
@ -126,6 +127,7 @@ case $POWERLEVEL9K_MODE in
VCS_SVN_ICON '(svn) ' VCS_SVN_ICON '(svn) '
RUST_ICON $'\uE6A8' #  RUST_ICON $'\uE6A8' # 
PYTHON_ICON $'\U1F40D' # 🐍 PYTHON_ICON $'\U1F40D' # 🐍
SWIFT_ICON ''
) )
;; ;;
*) *)
@ -180,6 +182,7 @@ case $POWERLEVEL9K_MODE in
VCS_SVN_ICON '' VCS_SVN_ICON ''
RUST_ICON '' RUST_ICON ''
PYTHON_ICON '' PYTHON_ICON ''
SWIFT_ICON 'Swift'
) )
;; ;;
esac esac

@ -41,7 +41,7 @@ else
POWERLEVEL9K_INSTALLATION_PATH="$0" POWERLEVEL9K_INSTALLATION_PATH="$0"
fi fi
# Resolve the instllation path # Resolve the installation path
if [[ -L "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then if [[ -L "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then
# If this theme is sourced as a symlink, we need to locate the real URL # If this theme is sourced as a symlink, we need to locate the real URL
filename="$(realpath -P $POWERLEVEL9K_INSTALLATION_PATH 2>/dev/null || readlink -f $POWERLEVEL9K_INSTALLATION_PATH 2>/dev/null || perl -MCwd=abs_path -le 'print abs_path readlink(shift);' $POWERLEVEL9K_INSTALLATION_PATH 2>/dev/null)" filename="$(realpath -P $POWERLEVEL9K_INSTALLATION_PATH 2>/dev/null || readlink -f $POWERLEVEL9K_INSTALLATION_PATH 2>/dev/null || perl -MCwd=abs_path -le 'print abs_path readlink(shift);' $POWERLEVEL9K_INSTALLATION_PATH 2>/dev/null)"
@ -106,7 +106,7 @@ fi
# name. From this function name, we strip the "prompt_"-prefix and # name. From this function name, we strip the "prompt_"-prefix and
# uppercase it. This is then prefixed with "POWERLEVEL9K_" and suffixed # uppercase it. This is then prefixed with "POWERLEVEL9K_" and suffixed
# with either "_BACKGROUND" or "_FOREGROUND", thus giving us the variable # with either "_BACKGROUND" or "_FOREGROUND", thus giving us the variable
# name. So each new segment is user-overwritable by a variable following # name. So each new segment is user-overwritten by a variable following
# this naming convention. # this naming convention.
################################################################ ################################################################
@ -117,7 +117,7 @@ CURRENT_BG='NONE'
# Begin a left prompt segment # Begin a left prompt segment
# Takes four arguments: # Takes four arguments:
# * $1: Name of the function that was orginally invoked (mandatory). # * $1: Name of the function that was originally invoked (mandatory).
# Necessary, to make the dynamic color-overwrite mechanism work. # Necessary, to make the dynamic color-overwrite mechanism work.
# * $2: The array index of the current segment # * $2: The array index of the current segment
# * $3: Background color # * $3: Background color
@ -207,7 +207,7 @@ CURRENT_RIGHT_BG='NONE'
# Begin a right prompt segment # Begin a right prompt segment
# Takes four arguments: # Takes four arguments:
# * $1: Name of the function that was orginally invoked (mandatory). # * $1: Name of the function that was originally invoked (mandatory).
# Necessary, to make the dynamic color-overwrite mechanism work. # Necessary, to make the dynamic color-overwrite mechanism work.
# * $2: The array index of the current segment # * $2: The array index of the current segment
# * $3: Background color # * $3: Background color
@ -973,6 +973,17 @@ prompt_pyenv() {
fi fi
} }
# Swift version
prompt_swift_version() {
local swift_version=($(swift --version 2>/dev/null))
[[ -z "${swift_version}" ]] && return
# Extract semantic version
swift_version=$(echo ${swift_version} | sed -e 's/[^0-9.]*\([0-9.]*\).*/\1/')
"$1_prompt_segment" "$0" "$2" "magenta" "white" "${swift_version}" 'SWIFT_ICON'
}
################################################################ ################################################################
# Prompt processing and drawing # Prompt processing and drawing
################################################################ ################################################################

Loading…
Cancel
Save