summaryrefslogtreecommitdiff
path: root/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/dotnet.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/dotnet.zsh')
-rw-r--r--dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/dotnet.zsh40
1 files changed, 40 insertions, 0 deletions
diff --git a/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/dotnet.zsh b/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/dotnet.zsh
new file mode 100644
index 00000000..66324384
--- /dev/null
+++ b/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/dotnet.zsh
@@ -0,0 +1,40 @@
+#
+# .NET
+#
+# .NET Framework is a software framework developed by Microsoft.
+# It includes a large class library and provides language interoperability
+# across several programming languages.
+# Link: https://www.microsoft.com/net
+
+# ------------------------------------------------------------------------------
+# Configuration
+# ------------------------------------------------------------------------------
+
+SPACESHIP_DOTNET_SHOW="${SPACESHIP_DOTNET_SHOW=true}"
+SPACESHIP_DOTNET_PREFIX="${SPACESHIP_DOTNET_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
+SPACESHIP_DOTNET_SUFFIX="${SPACESHIP_DOTNET_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
+SPACESHIP_DOTNET_SYMBOL="${SPACESHIP_DOTNET_SYMBOL=".NET "}"
+SPACESHIP_DOTNET_COLOR="${SPACESHIP_DOTNET_COLOR="128"}"
+
+# ------------------------------------------------------------------------------
+# Section
+# ------------------------------------------------------------------------------
+
+# Show current version of .NET SDK
+spaceship_dotnet() {
+ [[ $SPACESHIP_DOTNET_SHOW == false ]] && return
+
+ [[ -f project.json || -f global.json || -f paket.dependencies || -n *.(cs|fs|x)proj(#qN^/) || -n *.sln(#qN^/) ]] || return
+
+ spaceship::exists dotnet || return
+
+ # dotnet-cli automatically handles SDK pinning (specified in a global.json file)
+ # therefore, this already returns the expected version for the current directory
+ local dotnet_version=$(dotnet --version 2>/dev/null)
+
+ spaceship::section \
+ "$SPACESHIP_DOTNET_COLOR" \
+ "$SPACESHIP_DOTNET_PREFIX" \
+ "${SPACESHIP_DOTNET_SYMBOL}${dotnet_version}" \
+ "$SPACESHIP_DOTNET_SUFFIX"
+}