Browse Source

Add support for chroot(s) in spaceship

Emmanuel Bouthenot 1 year ago
parent
commit
00f99736d7
1 changed files with 24 additions and 0 deletions
  1. 24 0
      .zsh/config/60_spaceship.zsh

+ 24 - 0
.zsh/config/60_spaceship.zsh

@@ -2,7 +2,25 @@
 # SpaceShip configuration
 #
 
+spaceship_chroot() {
+
+    [[ $SPACESHIP_CHROOT_SHOW == false ]] && return
+
+    if [[ -n "${CHROOT}" ]]; then
+        printf -v chroot_status "${CHROOT}"
+    fi
+
+    [[ -z "${chroot_status}" ]] && return
+
+    spaceship::section \
+        "${SPACESHIP_CHROOT_COLOR}" \
+        "${SPACESHIP_CHROOT_PREFIX}" \
+        "${SPACESHIP_CHROOT_SYMBOL}$chroot_status" \
+        "${SPACESHIP_CHROOT_SUFFIX}"
+}
+
 SPACESHIP_PROMPT_ORDER=(
+  chroot        # Chroot section
 # time          # Time stamps section
   user          # Username section
   dir           # Current directory section
@@ -50,8 +68,14 @@ SPACESHIP_PROMPT_ADD_NEWLINE=false
 SPACESHIP_PROMPT_SEPARATE_LINE=false
 SPACESHIP_CHAR_SYMBOL="❱ "
 
+SPACESHIP_USER_PREFIX=""
+
 SPACESHIP_DIR_PREFIX=""
 SPACESHIP_DIR_TRUNC_REPO=false
 
 SPACESHIP_HOST_PREFIX="@"
 
+SPACESHIP_CHROOT_COLOR="blue"
+SPACESHIP_CHROOT_SYMBOL="chroot:"
+SPACESHIP_CHROOT_SUFFIX=" "
+