-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
65 lines (58 loc) · 1.39 KB
/
Copy pathinstall.sh
File metadata and controls
65 lines (58 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
# Downloads all the dotfiles and copies them to ~
#
# Run it interactively (decide on conflicts):
# sh -i <(curl -s https://raw.githubusercontent.com/flesler/dotfiles/master/install.sh)
#
# Remove the -i to automatically override any conflicted file
DF=~/dotfiles
BKP=.bkp #~
if [ -d "$DF" ]; then
cd "$DF"
# -U for no update
if [[ "$*" != -*U* ]]; then
git pull --rebase
fi
else
git clone https://github.com/flesler/dotfiles.git "$DF"
cd "$DF"
fi
for src in $(find home ! -name home); do
dest="${src/home/~}"
# Create directories if missing on destination
if [ -d "$src" ]; then
mkdir -p "$dest"
continue
fi
if [ ! -f "$dest" ]; then
:
elif cmp -s "$src" "$dest"; then
# Same file, auto-skip
continue
# If conflicted AND interactive
elif [ -n "$PS1" ]; then
# git diff has colors unlike diff
git diff -U0 "$dest" "$src"
echo -n "$dest already exists. (s)kip, (o)verwrite, (b)ackup?"
read -sn 1 -p ' ' chr
echo
case $chr in
s) continue;;
o) ;;
b)
mv "$dest" "$dest$BKP"
echo "backed up to $dest$BKP";;
*)
echo "unknown letter '$chr', skipping"
continue;;
esac
fi
echo "copying to $dest"
cp "$src" "$dest"
# FIXME: Not really symlinking in Git Bash
#ln -sf "$src" "$dest"
done
# Create an empty one so the user notices it
touch ~/.bash_extras
# FIXME: (Re)source everything (not really working as it's a shell script)
. ~/.bashrc