aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/sh/vcs-ps1.sh (renamed from etc/bash/vcs-ps1.sh)35
1 files changed, 32 insertions, 3 deletions
diff --git a/etc/bash/vcs-ps1.sh b/etc/sh/vcs-ps1.sh
index 6e74e1d..d18a24a 100644
--- a/etc/bash/vcs-ps1.sh
+++ b/etc/sh/vcs-ps1.sh
@@ -110,7 +110,7 @@ error_marker() {
fi
}
-shell_level() {
+shell_status_level() {
if [ -n "${SHLVL:-}" ]; then
if [ -n "${TMUX:-}" ]; then
LVL=$((SHLVL - 1))
@@ -118,11 +118,40 @@ shell_level() {
LVL="$SHLVL"
fi
if [ "$LVL" != 1 ]; then
- color -c white "[$LVL] "
+ color -c white "$LVL"
+ if [ -n "${RANGER_LEVEL:-}" ]; then
+ color -c white '|'
+ color -c bluei 'r'
+ fi
fi
fi
}
+shell_status_jobs() {
+ JOBS="$(jobs -p | wc -l)"
+ if [ "$JOBS" != 0 ]; then
+ color -c red "$JOBS"
+ fi
+}
+
+shell_status() {
+ LEVEL="$(shell_status_level)"
+ JOBS="$(shell_status_jobs)"
+
+ if [ -z "$LEVEL" ] && [ -z "$JOBS" ]; then
+ return
+ fi
+
+ color -c white '['
+ printf '%s' "$LEVEL"
+ if [ -n "$LEVEL" ] && [ -n "$JOBS" ]; then
+ color -c white '|'
+ fi
+ printf '%s' "$JOBS"
+ color -c white ']'
+ printf ' '
+}
+
timestamp() {
color -c blacki '\T'
}
@@ -154,7 +183,7 @@ in_nix_shell() {
fi
}
-PS1='`error_marker`'$(timestamp)' '$(path)' `shell_level``repo_status``guix_env``in_nix_shell`
+PS1='`error_marker`'$(timestamp)' '$(path)' `shell_status``repo_status``guix_env``in_nix_shell`
$ '