summaryrefslogtreecommitdiff
path: root/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/user.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/user.zsh')
-rw-r--r--dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/user.zsh50
1 files changed, 50 insertions, 0 deletions
diff --git a/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/user.zsh b/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/user.zsh
new file mode 100644
index 00000000..745c3c7f
--- /dev/null
+++ b/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/user.zsh
@@ -0,0 +1,50 @@
+#
+# Username
+#
+
+# ------------------------------------------------------------------------------
+# Configuration
+# ------------------------------------------------------------------------------
+
+# --------------------------------------------------------------------------
+# | SPACESHIP_USER_SHOW | show username on local | show username on remote |
+# |---------------------+------------------------+-------------------------|
+# | false | never | never |
+# | always | always | always |
+# | true | if needed | always |
+# | needed | if needed | if needed |
+# --------------------------------------------------------------------------
+
+SPACESHIP_USER_SHOW="${SPACESHIP_USER_SHOW=true}"
+SPACESHIP_USER_PREFIX="${SPACESHIP_USER_PREFIX="with "}"
+SPACESHIP_USER_SUFFIX="${SPACESHIP_USER_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
+SPACESHIP_USER_COLOR="${SPACESHIP_USER_COLOR="yellow"}"
+SPACESHIP_USER_COLOR_ROOT="${SPACESHIP_USER_COLOR_ROOT="red"}"
+
+# ------------------------------------------------------------------------------
+# Section
+# ------------------------------------------------------------------------------
+
+spaceship_user() {
+ [[ $SPACESHIP_USER_SHOW == false ]] && return
+
+ if [[ $SPACESHIP_USER_SHOW == 'always' ]] \
+ || [[ $LOGNAME != $USER ]] \
+ || [[ $UID == 0 ]] \
+ || [[ $SPACESHIP_USER_SHOW == true && -n $SSH_CONNECTION ]]
+ then
+ local 'user_color'
+
+ if [[ $USER == 'root' ]]; then
+ user_color=$SPACESHIP_USER_COLOR_ROOT
+ else
+ user_color="$SPACESHIP_USER_COLOR"
+ fi
+
+ spaceship::section \
+ "$user_color" \
+ "$SPACESHIP_USER_PREFIX" \
+ '%n' \
+ "$SPACESHIP_USER_SUFFIX"
+ fi
+}