summaryrefslogtreecommitdiff
path: root/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/host.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/host.zsh')
-rw-r--r--dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/host.zsh46
1 files changed, 46 insertions, 0 deletions
diff --git a/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/host.zsh b/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/host.zsh
new file mode 100644
index 00000000..23c8700a
--- /dev/null
+++ b/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/host.zsh
@@ -0,0 +1,46 @@
+#
+# Hostname
+#
+
+# ------------------------------------------------------------------------------
+# Configuration
+# ------------------------------------------------------------------------------
+
+SPACESHIP_HOST_SHOW="${SPACESHIP_HOST_SHOW=true}"
+SPACESHIP_HOST_SHOW_FULL="${SPACESHIP_HOST_SHOW_FULL=false}"
+SPACESHIP_HOST_PREFIX="${SPACESHIP_HOST_PREFIX="at "}"
+SPACESHIP_HOST_SUFFIX="${SPACESHIP_HOST_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
+SPACESHIP_HOST_COLOR="${SPACESHIP_HOST_COLOR="blue"}"
+SPACESHIP_HOST_COLOR_SSH="${SPACESHIP_HOST_COLOR_SSH="green"}"
+
+# ------------------------------------------------------------------------------
+# Section
+# ------------------------------------------------------------------------------
+
+# If there is an ssh connections, current machine name.
+spaceship_host() {
+ [[ $SPACESHIP_HOST_SHOW == false ]] && return
+
+ if [[ $SPACESHIP_HOST_SHOW == 'always' ]] || [[ -n $SSH_CONNECTION ]]; then
+ local host_color host
+
+ # Determination of what color should be used
+ if [[ -n $SSH_CONNECTION ]]; then
+ host_color=$SPACESHIP_HOST_COLOR_SSH
+ else
+ host_color=$SPACESHIP_HOST_COLOR
+ fi
+
+ if [[ $SPACESHIP_HOST_SHOW_FULL == true ]]; then
+ host="%M"
+ else
+ host="%m"
+ fi
+
+ spaceship::section \
+ "$host_color" \
+ "$SPACESHIP_HOST_PREFIX" \
+ "$host" \
+ "$SPACESHIP_HOST_SUFFIX"
+ fi
+}