aboutsummaryrefslogtreecommitdiff
path: root/etc/sh/rc
diff options
context:
space:
mode:
Diffstat (limited to 'etc/sh/rc')
-rw-r--r--etc/sh/rc87
1 files changed, 86 insertions, 1 deletions
diff --git a/etc/sh/rc b/etc/sh/rc
index abb3994..7bde008 100644
--- a/etc/sh/rc
+++ b/etc/sh/rc
@@ -144,7 +144,92 @@ alias flush='sync && echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null'
# PS1
#
-. "$XDG_CONFIG_HOME"/sh/vcs-ps1.sh
+repo_status() {
+ vcs ps1
+}
+
+error_marker() {
+ STATUS=$?
+ if [ "$STATUS" != 0 ]; then
+ color -c redb " (!! $STATUS !!) "
+ fi
+}
+
+shell_status_level() {
+ if [ -n "${SHLVL:-}" ]; then
+ if [ -n "${TMUX:-}" ]; then
+ LVL=$((SHLVL - 1))
+ else
+ LVL="$SHLVL"
+ fi
+ if [ "$LVL" != 1 ]; then
+ color -c white "$LVL"
+ if [ -n "${RANGER_LEVEL:-}" ]; then
+ color -c white '|'
+ color -c bluei 'r'
+ fi
+ fi
+ fi
+}
+
+shell_status_jobs() {
+ JOBS="$(jobs | grep -cv autojump)"
+ 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'
+}
+
+path() {
+ color -c yellowb '\w/'
+}
+
+guix_env() {
+ if [ -n "${GUIX_ENVIRONMENT:-}" ]; then
+ printf '\n'
+ color -c blacki '~> '
+ color -c purple 'guix environment '
+ printf '('
+ color -c blueb "$GUIX_ENVIRONMENT"
+ printf ')'
+ fi
+}
+
+in_nix_shell() {
+ if [ -n "${IN_NIX_SHELL:-}" ]; then
+ printf '\n'
+ color -c blacki '~> '
+ color -c purpleb "$IN_NIX_SHELL "
+ color -c purple 'nix-shell '
+ printf '('
+ color -c blueb "${name:-}"
+ printf ')'
+ fi
+}
+
+PS1='`error_marker`'$(timestamp)' '$(path)' `shell_status``repo_status``guix_env``in_nix_shell`
+$ '