3 # To start tracking a file,
4 # cp ~/.screenrc dot/screenrc
6 # To sort out symlinks when things are clean
7 # infra/makelinks install
9 set -e -o posix -o pipefail
12 echo >&2 "usage: $0 [-n|-v] list|setup|dirimport|dirmove|clean"
19 if [ $# = 0 ]; then break; fi
21 -n) real_act=log_only ;;
22 -v) real_act=with_log ;;
30 1.list|1.setup|1.import|1.dirimport|1.clean) ;;
37 basepath=${basepath#$HOME/}
46 if [ $mode = list ]; then
53 show "bad: $dot: $1" >&2
57 if [ $mode = $1 ]; then
59 show "DOING $1: $prhome ($2)"
61 show "needs $1: $prhome: $2"
75 dots=$( find dot -mindepth 1 -maxdepth 1 -name '[0-9a-zA-Z]*[0-9a-zA-Z]' )
79 underhome=".${dot#dot/}"
80 inhome="$HOME/$underhome"
82 linktarget="$basepath/$ours"
83 if [ "$inhome" -ef "$ours" ]; then
84 good "already symlinked here"
85 elif [ -h "$inhome" ]; then
86 bad "wrong symlink target"
87 elif ! [ -e "$inhome" ]; then
88 needs setup "absent here"
89 $act ln -s "$basepath/$dot" "$inhome"
90 elif [ -f "$inhome" ] && [ -f "$ours" ]; then
91 if cmp -s "$ours" "$inhome"; then
92 needs setup "identical here but not yet symlinked"
94 $act ln -s "$linktarget" "$inhome"~
95 $act mv -f "$inhome"~ "$inhome"
97 needs import "modified here"
99 $act cp "$inhome" "$ours"~
100 $act mv -f "$ours"~ "$ours"
102 elif [ -d "$inhome" ] && [ -d "$ours" ]; then
103 needs dirimport "directory here not yet symlinked"
104 $act mv "$ours" "$ours~"
105 $act ln -s "$linktarget" "$inhome"~
106 $act mv "$inhome" "$ours"
107 $act mv "$inhome~" "$inhome"
110 bad "mismatched file types"
116 find -L .[0-9a-zA-Z]* -maxdepth 0 -xdev -type l -lname "$basepath/dot/*"
118 for underhome in $brokens; do
119 inhome="$HOME/$underhome"
120 prhome="~/$underhome"
121 needs clean "symlink to removed file in dot/"