diff options
author | EuAndreh <eu@euandre.org> | 2022-08-12 19:05:56 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2022-08-12 19:05:56 -0300 |
commit | 3d4ee814546af5347f3c7665b71293b1a208b0eb (patch) | |
tree | aafb5a1c2a436547463871664909c3310b6237a9 | |
parent | etc/tmux/tmux.conf: Use "-" like "cd -" does (diff) | |
download | dotfiles-3d4ee814546af5347f3c7665b71293b1a208b0eb.tar.gz dotfiles-3d4ee814546af5347f3c7665b71293b1a208b0eb.tar.xz |
etc/{bash => sh}/vcs-ps1.sh: Add shell_status_jobs and shell_status_level
-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` $ ' |