diff options
author | EuAndreh <eu@euandre.org> | 2025-06-06 04:23:13 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2025-06-06 04:23:13 -0300 |
commit | 3cb8c61be96bd26dec868f23cba9de3e6c3fcfaf (patch) | |
tree | 078e27f5888092d8b9b007106d70ecc886d08ee6 /bin | |
parent | etc/guix/home.scm: Add "ngircd" and "inspircd" package (diff) | |
download | dotfiles-3cb8c61be96bd26dec868f23cba9de3e6c3fcfaf.tar.gz dotfiles-3cb8c61be96bd26dec868f23cba9de3e6c3fcfaf.tar.xz |
Add pijul package and configuration
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/vcs | 46 |
1 files changed, 46 insertions, 0 deletions
@@ -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 } |