aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/sh/rc87
-rw-r--r--etc/sh/vcs-ps1.sh102
2 files changed, 86 insertions, 103 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`
+$ '
diff --git a/etc/sh/vcs-ps1.sh b/etc/sh/vcs-ps1.sh
deleted file mode 100644
index e12c042..0000000
--- a/etc/sh/vcs-ps1.sh
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/bin/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`
-$ '
-
-
-vcs_status() {
- git status "$@"
-}
-
-vcs_diff() {
- git diff "$@"
-}
-
-vcs_diff_staged() {
- git diff --staged "$@"
-}