new prompt segment: dotnet_version

To enable this segment:

  1. Run `p10k configure`.
  2. Open `~/.p10k.zsh` and search for `dotnet_version`.
  3. Uncomment the first occurrence.

Fixes #233.
pull/243/head
romkatv 5 years ago
parent 5f08c5493f
commit 4a4f7e1eef

@ -53,6 +53,7 @@
# node_version # node.js version # node_version # node.js version
# go_version # go version (https://golang.org) # go_version # go version (https://golang.org)
# rust_version # rustc version (https://www.rust-lang.org) # rust_version # rustc version (https://www.rust-lang.org)
# dotnet_version # .NET version (https://dotnet.microsoft.com)
rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv)
rvm # ruby version from rvm (https://rvm.io) rvm # ruby version from rvm (https://rvm.io)
kubecontext # current kubernetes context (https://kubernetes.io/) kubecontext # current kubernetes context (https://kubernetes.io/)
@ -575,6 +576,14 @@
# Custom icon. # Custom icon.
# typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐'
###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################
# .NET version color.
typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134
# Show .NET version only when in a .NET project subdirectory.
typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true
# Custom icon.
# typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐'
#############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]##############
# Rbenv color. # Rbenv color.
typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168

@ -53,6 +53,7 @@
# node_version # node.js version # node_version # node.js version
# go_version # go version (https://golang.org) # go_version # go version (https://golang.org)
# rust_version # rustc version (https://www.rust-lang.org) # rust_version # rustc version (https://www.rust-lang.org)
# dotnet_version # .NET version (https://dotnet.microsoft.com)
rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv)
rvm # ruby version from rvm (https://rvm.io) rvm # ruby version from rvm (https://rvm.io)
kubecontext # current kubernetes context (https://kubernetes.io/) kubecontext # current kubernetes context (https://kubernetes.io/)
@ -554,6 +555,14 @@
# Custom icon. # Custom icon.
# typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐'
###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################
# .NET version color.
typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134
# Show .NET version only when in a .NET project subdirectory.
typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true
# Custom icon.
# typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐'
#############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]##############
# Rbenv color. # Rbenv color.
typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168

@ -113,6 +113,7 @@ function _p9k_init_icons() {
RANGER_ICON '\u2B50' # ⭐ RANGER_ICON '\u2B50' # ⭐
TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️
PROXY_ICON '\u2B82' # ⮂ PROXY_ICON '\u2B82' # ⮂
DOTNET_ICON '.NET'
) )
;; ;;
'awesome-fontconfig') 'awesome-fontconfig')
@ -213,6 +214,7 @@ function _p9k_init_icons() {
RANGER_ICON '\u2B50' # ⭐ RANGER_ICON '\u2B50' # ⭐
TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️
PROXY_ICON '\u2B82' # ⮂ PROXY_ICON '\u2B82' # ⮂
DOTNET_ICON '.NET'
) )
;; ;;
'awesome-mapped-fontconfig') 'awesome-mapped-fontconfig')
@ -317,6 +319,7 @@ function _p9k_init_icons() {
RANGER_ICON '\u2B50' # ⭐ RANGER_ICON '\u2B50' # ⭐
TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️
PROXY_ICON '\u2B82' # ⮂ PROXY_ICON '\u2B82' # ⮂
DOTNET_ICON '.NET'
) )
;; ;;
'nerdfont-complete'|'nerdfont-fontconfig') 'nerdfont-complete'|'nerdfont-fontconfig')
@ -418,6 +421,7 @@ function _p9k_init_icons() {
RANGER_ICON '\u2B50' # ⭐ RANGER_ICON '\u2B50' # ⭐
TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️
PROXY_ICON '\u2B82' # ⮂ PROXY_ICON '\u2B82' # ⮂
DOTNET_ICON '\uE77F' # 
) )
;; ;;
*) *)
@ -518,6 +522,7 @@ function _p9k_init_icons() {
RANGER_ICON '\u2B50' # ⭐ RANGER_ICON '\u2B50' # ⭐
TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️
PROXY_ICON '\u2B82' # ⮂ PROXY_ICON '\u2B82' # ⮂
DOTNET_ICON '.NET'
) )
;; ;;
esac esac

@ -1627,7 +1627,7 @@ prompt_load() {
} }
function _p9k_cached_cmd_stdout() { function _p9k_cached_cmd_stdout() {
local cmd=$commands[$1] local cmd=${commands[$1]:A}
[[ -n $cmd ]] || return [[ -n $cmd ]] || return
shift shift
local -H stat local -H stat
@ -1642,7 +1642,7 @@ function _p9k_cached_cmd_stdout() {
} }
function _p9k_cached_cmd_stdout_stderr() { function _p9k_cached_cmd_stdout_stderr() {
local cmd=$commands[$1] local cmd=${commands[$1]:A}
[[ -n $cmd ]] || return [[ -n $cmd ]] || return
shift shift
local -H stat local -H stat
@ -1844,6 +1844,22 @@ prompt_nodenv() {
_p9k_prompt_segment "$0" "black" "green" 'NODE_ICON' 0 '' "${v//\%/%%}" _p9k_prompt_segment "$0" "black" "green" 'NODE_ICON' 0 '' "${v//\%/%%}"
} }
prompt_dotnet_version() {
(( $+commands[dotnet] )) || return
if (( _POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY )); then
local dir=$_p9k_pwd
while true; do
[[ $dir == / ]] && return
[[ -n $dir/(project.json|global.json|packet.dependencies|*.csproj|*.fsproj|*.xproj|*.sln)(#qN^/) ]] && break
dir=${dir:h}
done
fi
_p9k_cached_cmd_stdout dotnet --version || return
_p9k_prompt_segment "$0" "magenta" "white" 'DOTNET_ICON' 0 '' "$_p9k_ret"
}
################################################################ ################################################################
# Segment to print a little OS icon # Segment to print a little OS icon
prompt_os_icon() { prompt_os_icon() {
@ -3821,6 +3837,7 @@ _p9k_init_params() {
_p9k_declare -i POWERLEVEL9K_LOAD_WHICH 5 _p9k_declare -i POWERLEVEL9K_LOAD_WHICH 5
_p9k_declare -b POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -b POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW 0
_p9k_declare -b POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY 0 _p9k_declare -b POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY 0
_p9k_declare -b POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY 1
_p9k_declare -b POWERLEVEL9K_GO_VERSION_PROJECT_ONLY 1 _p9k_declare -b POWERLEVEL9K_GO_VERSION_PROJECT_ONLY 1
_p9k_declare -b POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY 1 _p9k_declare -b POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY 1
_p9k_declare -b POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -b POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW 0

Loading…
Cancel
Save