From 3cb8c61be96bd26dec868f23cba9de3e6c3fcfaf Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 6 Jun 2025 04:23:13 -0300 Subject: Add pijul package and configuration --- bin/vcs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ etc/guix/home.scm | 1 + etc/sh/rc | 2 +- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/bin/vcs b/bin/vcs index bf12527..73a2925 100755 --- a/bin/vcs +++ b/bin/vcs @@ -4,6 +4,7 @@ set -eu TYPES=' git +pijul fossil bitkeeper darcs @@ -15,6 +16,8 @@ cvs guess_type() { if [ -e "$1"/.git ] || { [ -n "${GIT_DIR:-}" ] && [ -n "$GIT_WORK_TREE" ]; }; then echo git + elif [ -e "$1"/.pijul ]; then + echo pijul elif [ -e "$1"/.hg ]; then echo mercurial elif [ -e "$1"/.bk ]; then @@ -135,6 +138,45 @@ git_ps1() { color -c blacki " - git/$(git rev-parse HEAD)" } +pijul_ps1() { + LINE="$(pijul channel | awk '$1 == "*" && $0=$2')" + + DIFF_LINES="$(pijul diff -u -s)" + HAS_DIFF=false + HAS_UNTRACKED=false + if printf '%s\n' "$DIFF_LINES" | grep -q '^[A|D|M|R| ][M|D| ]'; then + HAS_DIFF=true + fi + if printf '%s\n' "$DIFF_LINES" | grep -Eq '^([?][?]| A)'; then + HAS_UNTRACKED=true + fi + + if [ "$HAS_DIFF" = true ]; then + COLOR_FN=redb + LINE="{$LINE}" + elif [ "$IS_AHEAD" = true ] || [ "$IS_BEHIND" = true ]; then + COLOR_FN=bluei + LINE="[$LINE]" + elif [ "$HAS_UNTRACKED" = true ]; then + COLOR_FN=lightblue + LINE="{$LINE}" + else + COLOR_FN=green + LINE="($LINE)" + fi + + color -c "$COLOR_FN" "$LINE" + + CHANNEL_COUNT="$(pijul channel | wc -l)" + if [ "$CHANNEL_COUNT" -gt 1 ]; then + color -c lightblue "<$CHANNEL_COUNT>" + fi + + CHANGEID="$(pijul log --limit 1 --output-format json | + jq -r '.[0].hash')" + color -c blacki " - pijul/$CHANGEID" +} + bitkeeper_ps1() { printf '' } @@ -178,6 +220,10 @@ git_ls() { git ls-files } +pijul_ls() { + pijul ls +} + fossil_ls() { fossil ls } diff --git a/etc/guix/home.scm b/etc/guix/home.scm index 5ca5875..e4a47a2 100644 --- a/etc/guix/home.scm +++ b/etc/guix/home.scm @@ -153,6 +153,7 @@ cvs subversion quilt + pijul ;; urubu gperftools diff --git a/etc/sh/rc b/etc/sh/rc index f6052ef..48d83c5 100644 --- a/etc/sh/rc +++ b/etc/sh/rc @@ -210,7 +210,7 @@ alias diff='diff --color=auto' alias watch='watch --color ' alias man='MANWIDTH=$((COLUMNS > 80 ? 80 : COLUMNS)) man' alias less='less -R' -alias tree='tree -F -aC -I .git -I vendor -I STUFF -I refers' +alias tree='tree -F -aC -I .git -I .pijul -I vendor -I STUFF -I refers' alias make='make -e --no-print-directory' alias mv='mv -i' alias bc='bc -lq' -- cgit v1.2.3