dot

packages and services management
Log | Files | Refs | README

commit e55c3405157207a4f4e691ae51247c3d52b7b302
parent e3a0385428243831ade45bc06873eab853643178
Author: josuah <mail@josuah.net>
Date:   Fri, 16 Sep 2016 11:00:34 -0400

Added lsync back, fixed version

Diffstat:
Mbin/agenda | 8++++----
Abin/lsync | 116+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ms-nail/.mailrc | 4+++-
Mxorg/.xinitrc | 5++---
4 files changed, 125 insertions(+), 8 deletions(-)

diff --git a/bin/agenda b/bin/agenda @@ -107,7 +107,7 @@ BEGIN { printf("_%4s_________Summary__________________________________"\ "Location____________________________________________" \ "____________________________________________________" \ - "\n │\n", + "\n |\n", beg_Y); } @@ -115,16 +115,16 @@ BEGIN { if (last_beg_m != beg_m) {printf("%2s ", beg_m);} else {printf(" ");} if (last_beg_d != beg_d) {printf("%2s ", beg_d);} else {printf(" ");} - printf("%5s │ %-40s %s\n", beg_R, sum, loc); + printf("%5s | %-40s %s\n", beg_R, sum, loc); # Second line if (beg_m != end_m) {printf("%2s ", end_m);} else {printf(" ");} if (beg_d != end_d) {printf("%2s ", end_d);} else {printf(" ");} if (beg_R != end_R) {printf("%5s ", end_R);} else {printf(" ");} - printf("│\033[30;1m %s", des); + printf("|\033[30;1m %s", des); - printf("\n\033[0m │\n"); + printf("\n\033[0m |\n"); last_beg_Y = beg_Y; last_beg_m = beg_m; diff --git a/bin/lsync b/bin/lsync @@ -0,0 +1,116 @@ +#!/bin/sh +# /\ +# / / ____ __ /\ ____ ____ +# / / / __// / / // __ \ / ___\ +# / /__\ \ \ \/ // / / // /__ +# \/ \___/ __\ / \/ \/ \____\ - Sync from two local dirs +#==========\__,'================================================================ + +help=' +NAME + LSync - Mirror two local dirs keeping the latest version + +SYNTAX + lsync [-v] [-e PATTERN] DIR1 ['RULE'] DIR2 + +OPTIONS + -e Exclude PATTERN from search, matching the whole path. + -v View the output without copying anything. + DIR The two directories to mirror. + RULE Rule to determine in which operation to perform. + > and < only copy, + >> and << copy and overwrite, + >>> and <<< only overwrite, + none means everything. + +USAGE + LSync mirrors data across two directories so that both contains all the + files from each other keeping the timestapms. + + When a file exists in both directories, if they do not have the same + timestamps, the most recent file overwrite the other. + + There is no deletion performed.' + +[ $# -lt 2 ] && printf '%s\n\n' "$help" && exit 0 + +while [ $# -gt 0 ] +do case "$1" in + '-e' ) e="$2"; shift ;; + '-v' ) v=1 ;; + '>' | '>>' | '>>>' | '<<<' | '<<' | '<' ) r="$1" ;; + '-'* ) printf '%s\n\n' "$help"; exit 0 ;; + * ) [ -z "$d1" ] && d1="${1%/}" || d2="${1%/}" ;; + esac + shift +done + +[ ! -d "$d1" ] && mkdir -p "$d1" +[ ! -d "$d2" ] && mkdir -p "$d2" + +copied=0; overwritten=0; directories=0; identical=0 + +# Generate a path list for all the files from both directories +{ + find "$d1" | cut -c $((${#d1} + 1))- + find "$d2" | cut -c $((${#d2} + 1))- +} | sort -u | { + [ -z "$e" ] && tee || grep -v "$e" +} | { + while read -r path + do + # Create directories + if [ -d "$d1/$path" ] || [ -d "$d2/$path" ] + then [ -z "$v" ] && mkdir -p "$d1/$path" "$d2/$path" + printf '\033[1;30m ' + directories=$(($directories + 1)) + + # Copy files that does not exist on one side + elif [ ! -e "$d2/$path" ] + then if [ "$r" = '>' -o "$r" = '>>' -o -z "$r" ] + then b=';1' copied=$(($copied + 1)) + [ -z "$v" ] && cp -p "$d1/$path" "$d2/$path" + fi + printf '\033[32%sm1 > 2\033[0%sm' "$b" "$b" + + elif [ ! -e "$d1/$path" ] + then if [ "$r" = '<' -o "$r" = '<<' -o -z "$r" ] + then b=';1' copied=$(($copied + 1)) + [ -z "$v" ] && cp -p "$d2/$path" "$d1/$path" + fi + printf '\033[32%sm1 < 2\033[0%sm' "$b" "$b" + + # Compare both file to check if identical + elif cmp -s "$d1/$path" "$d2/$path" + then identical=$(($identical + 1)) + printf '1 = 2' + + # Overwrite files keeping the latest version + elif [ "$d1/$path" -nt "$d2/$path" ] + then if [ "$r" = '>>>' -o "$r" = '>>' -o -z "$r" ] + then b=';1' overwritten=$(($overwritten + 1)) + [ -z "$v" ] && cp -pf "$d1/$path" "$d2/$path" + fi + printf '\033[31%sm1>>>2\033[0%sm' "$b" "$b" + + elif [ "$d2/$path" -nt "$d1/$path" ] + then if [ "$r" = '<<<' -o "$r" = '<<' -o -z "$r" ] + then b=';1' overwritten=$(($overwritten + 1)) + [ -z "$v" ] && cp -pf "$d2/$path" "$d1/$path" + fi + printf '\033[31%sm1<<<2\033[0%sm' "$b" "$b" + fi + + unset b + printf ' %s\033[0m\n' "$path" + done + + printf ' \ \ %-40s \033[1;32m%5s\033[0m copied + \ \__ %-40s \033[1;31m%5s\033[0m overwritten + \_____ %-40s \033[1;39m%5s\033[0m identical + %-40s \033[1;30m%5s\033[0m directories\n' \ + '' "$copied" \ + "$d2" "$overwritten" \ + "$d1" "$identical" \ + '' "$directories" +} diff --git a/s-nail/.mailrc b/s-nail/.mailrc @@ -128,7 +128,7 @@ define filter { move (from "reddit") ~/Mail/l.reddit - move (from "nixers.net") ~/Mail/l.nixers.net + move (from "nixers.net") ~/Mail/l.nixers move (from "sachachua.com") ~/Mail/l.sachachua @@ -148,6 +148,8 @@ define filter { move (from "github.com") ~/Mail/s.github + move (from "stackexchange.com") ~/Mail/s.stackexchange + move (from "twitter.com") ~/Mail/s.twitter move (from "bandcamp.com") ~/Mail/s.bandcamp diff --git a/xorg/.xinitrc b/xorg/.xinitrc @@ -10,8 +10,7 @@ done & nm-applet & xfce4-power-manager & -st TERM=screen abduco -A dvtm dvtm-status & -feh --bg-center "/home/josuah/Pictures/wallpaper."* -compton & +#feh --bg-center "/home/josuah/Pictures/wallpaper."* +#compton & exec dwm