dot

packages and services management
Log | Files | Refs | README

commit 8e655d823f55360bbe3c1f7c3becc1918c0448cc
parent 284d27e08d221dd78521b21e574e3b2ce5a09f9c
Author: josuah <mail@josuah.net>
Date:   Thu, 29 Dec 2016 18:01:35 +0100

Added a handy page function

Diffstat:
M.config/dwm/config.h | 2+-
M.local/bin/version | 69++++++++++++++++++++++++++++++++++++++++++---------------------------
M.profile | 2+-
3 files changed, 44 insertions(+), 29 deletions(-)

diff --git a/.config/dwm/config.h b/.config/dwm/config.h @@ -26,7 +26,7 @@ static const Rule rules[] = { */ /* class instance title tags mask isfloating monitor */ { "st-256color", NULL, NULL, 1, 0, -1 }, - { "chromium", NULL, NULL, 1 << 2, 0, -1 }, + { "Chromium", NULL, NULL, 1 << 2, 0, -1 }, { "Iceweasel", NULL, NULL, 1 << 2, 0, -1 }, { "Firefox", NULL, NULL, 1 << 2, 0, -1 }, { "Surf", NULL, NULL, 1 << 2, 0, -1 }, diff --git a/.local/bin/version b/.local/bin/version @@ -1,5 +1,6 @@ #!/bin/sh +# dependencies: # mkdir find sort xargs md5sum tail rm test mv comm sed uniq grep printf TAB=' ' NL=' @@ -9,9 +10,11 @@ TAB=' ' NL=' usage() { printf %s "\ -${0##*/} i[nit] create a new version directory in working directory -${0##*/} n[ew] create a new version entry -${0##*/} m[erge] TREE merge current tree with foreign TREE +${0##*/} i[nit] create a new version directory in working directory +${0##*/} n[ew] create a new version entry +${0##*/} l[ist] display full history of revisions +${0##*/} d[diff] [R1 [R2]] diff changes between R1 R2 (or latests) revisions +${0##*/} m[erge] TREE merge current tree with foreign TREE " exit 1 } @@ -99,7 +102,7 @@ merge() do printf '\n\n\n%s\n' "$root" - done | less + done } @@ -112,34 +115,34 @@ makediff() printf '\n\n: %s %s\n\n' "$1" "$2" # i: identical: same hash and same name - comm -12 "$root/.version/$1" "$root/.version/$2" | sed 's/^/i /' + comm -12 "$3/.version/$1" "$3/.version/$2" | sed 's/^/i /' # m: modified: same name, different content - comm -3 "$root/.version/$1" "$root/.version/$2" | sed 's/^\t//' | + comm -3 "$3/.version/$1" "$3/.version/$2" | sed 's/^\t//' | sort -b -t "$NL" -k 1.35 | uniq -ds 34 | sed 's/^/m /' # r: renamed: same hash, different name - comm -3 "$root/.version/$1" "$root/.version/$2" | sed 's/^\t//' | + comm -3 "$3/.version/$1" "$3/.version/$2" | sed 's/^\t//' | while read -r hash name do - grep -F "$hash" "$root/.version/$1" | sed 's/^/r /' + grep -F "$hash" "$3/.version/$1" | sed 's/^/r /' done # d: deleted: neither name nor hash present in the next revision while read -r hash name do - ! grep -F "$hash" "$root/.version/$2" > /dev/null && - ! grep -F "$name" "$root/.version/$2" > /dev/null && + ! grep -F "$hash" "$3/.version/$2" > /dev/null && + ! grep -F "$name" "$3/.version/$2" > /dev/null && printf 'd %s %s\n' "$hash" "$name" - done < "$root/.version/$1" + done < "$3/.version/$1" # c: created: neither name nor hash present in the previous while read -r hash name do - ! grep -F "$hash" "$root/.version/$1" > /dev/null && - ! grep -F "$name" "$root/.version/$1" > /dev/null && + ! grep -F "$hash" "$3/.version/$1" > /dev/null && + ! grep -F "$name" "$3/.version/$1" > /dev/null && printf 'c %s %s\n' "$hash" "$name" - done < "$root/.version/$2" + done < "$3/.version/$2" } @@ -149,17 +152,21 @@ makediff() # tracediff() { + [ -d "$3/.version" ] || die "no .version dir in $3" + # get all changes since "$1" revisions="$(cat "$3/.version/history")$NL" revisions="${revisions##*${1:-$( - sed + sed -n '$ p' "$3/.version/history" )}$NL}" + printf '%s\n' "$revisions" + # generate a diff of every revision with next one prev="$revision" for next in $revisions do - makediff "$prev" "$next" "$root" + makediff "$prev" "$next" "$3" prev="$next" done } @@ -167,28 +174,36 @@ tracediff() main() { - root="$(root)" - case "$1" in - ( i | init ) [ $# -ne 1 ] && usage - init "$root" + ( i | init ) + [ $# -ne 1 ] && usage + init "$(root)" ;; - ( n | new ) [ $# -ne 1 ] && usage - new "$root" + ( n | new ) + [ $# -ne 1 ] && usage + new "$(root)" ;; ( d | diff ) [ $# -gt 2 ] && [ ! -f ".version/$1" ] || [ $# -eq 3 ] && [ ! -f ".version/$2" ] || [ $# -gt 3 ] && usage - tracediff "$2" "$3" "$root" + tracediff "$2" "$3" "$(root)" + ;; + ( l | list ) + [ $# -gt 1 ] && usage + [ -d "$root/.version" ] || die "no .version dir in $PWD" + [ -f "$root/.version/history" ] || die "no revision in $PWD" + cat "$root/.version/history" ;; - ( m | merge ) [ $# -ne 2 ] && usage - merge "$root" "$2" + ( m | merge ) + [ $# -ne 2 ] && usage + merge "$(root)" "$2" ;; - ( * | '' ) usage + ( * | '' ) + usage ;; esac } -main "$@" +main "$@" | less -F diff --git a/.profile b/.profile @@ -71,7 +71,7 @@ alias lines='find . -name "*.[ch]" | xargs wc -l' page() { - "$@" | less -ER + "$@" | less -FR }