dot

packages and services management
Log | Files | Refs | README

commit 133dfde26bbf330ed4ca1d70f8e10bfe92d2025a
parent 8ec3533ad224cca59ec00e79e92f04c24b05b77a
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sun,  8 Jul 2018 13:12:46 +0200

pack: back to meaningful commands

Diffstat:
Abin/git-static | 43+++++++++++++++++++++++++++++++++++++++++++
Mbin/pack | 14+++++++-------
Mdot/profile | 6+++++-
3 files changed, 55 insertions(+), 8 deletions(-)

diff --git a/bin/git-static b/bin/git-static @@ -0,0 +1,43 @@ +#!/bin/sh -e + +test $# = 2 || exec echo "usage: $(basename "$0") base bare-repo" + +fmt='%H %ad %an <%ae>%n%s%n' +name=$(basename "$2" .git) +desc=$(test -f "$2/description" && sed q "$2/description") + +git -C "$2" log --format='%H' | while read h +do test -f "$h.txt" || git -C "$2" show -u --stat "$h" >$h.txt +done + +exec >index.gph +echo +echo "$name - $desc" +echo +git -C "$2" log --expand-tabs=8 --graph --date=short --format="$fmt" | +awk -v prefix="$1" ' + match($0, "[0-9a-f]{40}") { + gsub("[]\\\\|[]", "\\\\&"); + printf("[%s|/0/%s/%s.txt|server|port]\n", + substr($0, 1, RSTART) \ + substr($0, RSTART, 8) \ + substr($0, RSTART + RLENGTH), + prefix, + substr($0, RSTART, RLENGTH)); + next; + } + 1 +' + +exec >index.html +echo '<!doctype html><meta charset="UTF-8"/>' +echo "<title>$name</title><h1>$name - $desc</h1>" +echo '<pre>' +git -C "$2" log --graph --date=short --format="$fmt" | sed -r ' + s,&,\&amp;,g + s,<,\&lt;,g + s,>,\&gt;,g + s,",\&quot;,g + s,([0-9a-f]{8})([0-9a-f]{32}),<a href="\1\2.txt">\1</a>, +' +echo '</pre>' diff --git a/bin/pack b/bin/pack @@ -30,16 +30,16 @@ case $1 in read -r url path <$PACK/cvs cvs -qd "$url" checkout -P "$path" ;; -(get) test -f "$PACK/tar" && exec "$0" -t "$2" - test -f "$PACK/git" && exec "$0" -g "$2" - test -f "$PACK/cvs" && exec "$0" -c "$2" +(get) test -f "$PACK/tar" && exec "$0" tar "$2" + test -f "$PACK/git" && exec "$0" git "$2" + test -f "$PACK/cvs" && exec "$0" cvs "$2" ;; -(build) test -d "$SOURCE" || "$0" -d "$2" +(build) test -d "$SOURCE" || "$0" get "$2" cd "$SOURCE" mkdir -p "$PREFIX" exec "$PACK/build" ;; -(add) test -d "$PREFIX" || "$0" -b "$2" || rm -rf "$PREFIX" +(add) test -d "$PREFIX" || "$0" build "$2" || rm -rf "$PREFIX" cd "$PREFIX" find -L . -type d | xargs -n 1 -I {} mkdir -p "$DEST/{}" find -L . -type f | xargs -n 1 -I {} ln -sf "$PREFIX/{}" "$DEST/{}" @@ -48,9 +48,9 @@ case $1 in find . -type f | xargs -I {} rm -f "$DEST/{}" rm -rf "$PREFIX" ;; -(up) "$0" -r "$2" +(up) "$0" del "$2" rm -rf "$SOURCE" - "$0" -i "$2" + "$0" add "$2" ;; (*) echo 'usage: pack {tar,git,cvs,get,build,add,up} package' echo diff --git a/dot/profile b/dot/profile @@ -34,4 +34,8 @@ export SSH_AUTH_SOCK=$HOME/.ssh/agent # Prompt -export PS1=$(uname -n)$(test "$(whoami)" = root && echo '#' || echo '$')' ' +export PS1='$(test $? = 0 || printf "\\033[1;31mx\\033[m\n\r")' +export PS1=$PS1$(printf '\n\033];$PWD\a') +export PS1=$PS1$(uname -n) +export PS1=$PS1$(test "$(whoami)" = root && echo '#' || echo '$') +export PS1=$PS1' '