#!/usr/bin/env bash set -euo pipefail # Give an overview of the current state, including: # # * Current channel # * State of tracked files with changes # * Untracked files current_channel() { local c=$(pijul channel | grep '^\*') printf "On channel %s\n" "${c:2}" } pijul_status() { pijul diff --short --untracked | awk -f <(cat - <<-'EOD' BEGIN { ci = 0 ui = 0 } /^[MR] .*/ { changes[ci++] = "modified " substr($0, 3) } /^A .*/ { changes[ci++] = "added " substr($0, 3) } /^D .*/ { changes[ci++] = "deleted " substr($0, 3) } /^U .*/ { untracked[ui++] = substr($0, 3) } END { if (ci > 0) { printf("\nUnrecorded changes:\n") printf(" (use 'pijul record' to record a new patch)\n") printf(" (use 'pijul reset' to discard changes)\n") for (c in changes) { printf(" %s\n", changes[c]) } } if (ui > 0) { printf("\nUntracked files:\n") for (u in untracked) { printf(" %s\n", untracked[u]) } } if (ci == 0 && ui == 0) { printf("nothing to record, working copy clean\n") } } EOD ) } current_channel pijul_status