diff options
author | Thomas Paul Mann <hi@thomaspaulmann.com> | 2016-12-01 23:21:05 +0300 |
---|---|---|
committer | Thomas Paul Mann <hi@thomaspaulmann.com> | 2016-12-01 23:21:05 +0300 |
commit | 21a5cbd988531b5ca08afb6863f22e592170cdef (patch) | |
tree | 35a2c5b014dd13527c7e65a0ab6d7844801b3e4e | |
parent | 1ff9da64d974265ce2f22bd1da4a47d0b8f7ca90 (diff) |
Add prompt for current installed swift version
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | functions/icons.zsh | 3 | ||||
-rwxr-xr-x | powerlevel9k.zsh-theme | 12 |
3 files changed, 16 insertions, 1 deletions
@@ -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. * **Rust Segments:** * `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:** * **AWS Segments:** diff --git a/functions/icons.zsh b/functions/icons.zsh index 2f30cff2..bd1cfa06 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -72,6 +72,7 @@ case $POWERLEVEL9K_MODE in VCS_SVN_ICON '(svn) ' RUST_ICON '' PYTHON_ICON $'\U1F40D' # 🐍 + SWIFT_ICON '' ) ;; 'awesome-fontconfig') @@ -126,6 +127,7 @@ case $POWERLEVEL9K_MODE in VCS_SVN_ICON '(svn) ' RUST_ICON $'\uE6A8' # PYTHON_ICON $'\U1F40D' # 🐍 + SWIFT_ICON '' ) ;; *) @@ -180,6 +182,7 @@ case $POWERLEVEL9K_MODE in VCS_SVN_ICON '' RUST_ICON '' PYTHON_ICON '' + SWIFT_ICON 'Swift' ) ;; esac diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c06d1286..64662144 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -965,6 +965,17 @@ prompt_pyenv() { 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 ################################################################ @@ -1091,4 +1102,3 @@ powerlevel9k_init() { } powerlevel9k_init "$@" - |