diff options
| -rw-r--r-- | .bashrc | 5 | ||||
| -rw-r--r-- | .config/i3/config | 1 | ||||
| -rwxr-xr-x | bin/backup | 37 | ||||
| -rwxr-xr-x | bin/backup-clean | 9 | ||||
| -rwxr-xr-x | bin/byo | 5 | ||||
| -rwxr-xr-x | bin/diffdir | 21 |
6 files changed, 58 insertions, 20 deletions
@@ -32,6 +32,9 @@ fixab() { printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 "$1"; } #export LESS_TERMCAP_us=$(tput setaf 5) # underline (magenta) #export LESS_TERMCAP_ue=$'\E[0m' # end underline +# bat +export BAT_THEME='github' + # Stopwatch alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date' @@ -67,7 +70,7 @@ alias wpa='sudo wpa_gui -i wlan0' alias ifre='echo "ip link set wlo1 down; ip link set wlo1 up"|sudo sh' -alias by='go build cmd/yaegi/yaegi.go' +alias by='go build ./cmd/yaegi' alias cy='cd ~/go/src/github.com/containous/yaegi' #alias ty='go test -v -short ./interp' alias ya='rlwrap -pblue ./yaegi' diff --git a/.config/i3/config b/.config/i3/config index 757e202..677dc90 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -61,6 +61,7 @@ for_window [class="Gpicview"] floating enable for_window [class="Ghb"] floating enable for_window [class="Gitk"] floating enable for_window [class="gnuplot_qt"] floating enable +for_window [instance="gxditview"] floating enable for_window [class="Keybase"] floating enable for_window [class="libreoffice"] floating enable for_window [class="llpp"] floating enable @@ -3,21 +3,34 @@ [ "$USER" = root ] || exec sudo "$0" "$@" -while getopts :v opt; do +backup() { + date=$(date +%Y%m%d_%H%M%S) + last=$(rsync --list-only "$dest/" 2>/dev/null | cut -b 47- | tail -1) + + case $last in + ([12]*) opt_link=--link-dest=../$last;; + (*) opt_link=;; + esac + + rsync -HSxa$optv --exclude-from=$ignore $opt_link / /boot "$dest/$date" +} + +dest=/.history +ignore=/etc/backup/ignore + +while getopts :d:i:nv opt; do case $opt in - (v) eval "opt$opt=$opt" ;; - (*) echo "Usage: $0 [-v] [[host:]dir]"; exit 1 ;; + (d) dest="$OPTARG" ;; + (i) ignore="$OPTARG" ;; + (n|v) optv="$opt$optv" ;; + (*) echo "Usage: $0 [-nv] [-d [host:]dir] [clean|diff]"; exit 1 ;; esac done shift $((OPTIND - 1)) -dest=${1:-/.history} -date=$(date +%Y%m%d_%H%M%S) -last=$(rsync --list-only "$dest/" 2>/dev/null | cut -b 47- | tail -1) - -case $last in -([12]*) opt_link=--link-dest=../$last;; -(*) opt_link=;; +[ "$1" ] && cmd=$1 && shift || cmd="" +case $cmd in +(""|save) backup ;; +(clean) exec backup-clean ${optv+-$optv} "$@" "$dest";; +(diff) exec diffdir "$@";; esac - -rsync -HSxa$optv --exclude-from=/etc/backup/ignore $opt_link / /boot "$dest/$date" diff --git a/bin/backup-clean b/bin/backup-clean index 054ffbc..d12159d 100755 --- a/bin/backup-clean +++ b/bin/backup-clean @@ -26,7 +26,7 @@ date2ts() { t=$r; r=${t#??}; M=${t%$r} # Minute S=${t#??} # Second date -d "$Y-$m-$d $H:$M:$S" +%s - #date -jf "%Y-%m-%d %H:%M:%S" "$Y-$m-$d $H:$M:$S" +%s # BSD, MacOSX + #date -jf "%Y-%m-%d %H:%M:%S" "$Y-$m-$d $H:$M:$S" +%s # BSD, MacOS (not tested) } ts2date() { date -d "@$1" +'%Y%m%d_%H%M%S'; } @@ -53,17 +53,18 @@ retention_delay() { echo $r } -while getopts :nv opt; do +dest=/.history +while getopts :nd:v opt; do case $opt in + (d) dest=$OPTARG ;; (n) optn=1 ;; (v) optv=1 ;; - (*) echo "Usage: $0 [-nv] [dir]"; exit 1; + (*) echo "Usage: $0 [-nv] [-d dir]"; exit 1; esac done shift $((OPTIND - 1)) # Sorted list of backups, most recent first. -dest=${1:-/.history} lbu=$(ls -rv "$dest") for d in $lbu; do tsc=$(date2ts "$d") @@ -24,9 +24,10 @@ yoda_uuid='8c463221-6bb7-414e-9060-c9570bb3a6bb' dest=/mnt/backup/$(hostname) [ -b /dev/mapper/yoda ] && noclose=1 || cryptsetup open "$(blkid --uuid "$yoda_uuid")" yoda findmnt /dev/mapper/yoda /mnt >/dev/null && noumount=1 || mount /dev/mapper/yoda /mnt -time backup -v "$dest" -backup-clean -v "$dest" +time backup -v -d "$dest" +backup -v -d "$dest" clean [ ! "$optd" ] || time duperemove -drh --hashfile="$dest/.hashfile" "$dest" +df -h / "$dest" [ ! "$optk" ] || noumount=1 noclose=1 [ ! "$optc" ] || noumount='' noclose='' [ "$noumount" ] || umount /mnt diff --git a/bin/diffdir b/bin/diffdir index d1a8ae2..cbe03b7 100755 --- a/bin/diffdir +++ b/bin/diffdir @@ -32,6 +32,20 @@ diffdir() { #key ~ /[cps]/ { print "changed " prefix file }' } +last() { + i=0 m=0 + case $1 in + ([0-9]|[1-9][0-9]) m=$((m + $1)) ;; + ("") ;; + (*) echo "$1"; return ;; + esac + for l in $vlist; do + [ $i -ge $m ] && break + i=$((i + 1)) + done + echo "$dest/$l" +} + while getopts :V opt; do case $opt in (V) echo "$Version"; exit ;; @@ -40,4 +54,9 @@ while getopts :V opt; do done shift $((OPTIND - 1)) -diffdir "$1" "$2" +dest=/.history +vlist=$(rsync --list-only "$dest/" 2>/dev/null | cut -b 47- | tac) + +old=$(last "$1") new=$(last "${2:-/}") +echo "diffdir" "$old" "$new" +diffdir "$old" "$new" |
