-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·62 lines (49 loc) · 1.54 KB
/
install.sh
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
#!/bin/bash
set -e
set -u
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BACKUP_DIR="${DIR}_backup_$(date +%Y-%m-%d-%H:%M)"
IGNORE="^install\.sh$|\
^install-dependencies\.sh$|\
^README\.md$|\
^xmonad\.desktop$|\
^dependencies$"
echo "Installing dotfiles"
echo "Backup directory: $BACKUP_DIR"
echo
cd "$DIR"
files="$(git ls-files | egrep -v $IGNORE | sort)"
for file in $files ; do
home_file="$(readlink -f "$HOME/$file" || true)"
home_file="${home_file:-$HOME/$file}"
destination_file="$(readlink -f "$DIR/$file")"
if command -v realpath &> /dev/null ; then
destination_file_link=$(realpath --relative-to="$(dirname "$home_file")" "$destination_file")
else
destination_file_link="$destination_file"
fi
if [ "$home_file" != "$destination_file" ] ; then
echo "Needs linking: $file"
mkdir -v -p "$(dirname "$HOME/$file")" || true
if [ -e "$home_file" ] ; then
mkdir -p "$BACKUP_DIR" || true
mv -v "$home_file" "$BACKUP_DIR" || true
fi
ln -s -f -v "$destination_file_link" "$home_file"
else
echo "Nothing to do: $file"
fi
done
echo
echo "Initializing and updating git submodules"
git submodule update --init
echo "Installing urxvt extensions"
urxvt_ext="$DIR/.urxvt/ext/urxvt-font-size/font-size"
if command -v realpath &> /dev/null ; then
urxvt_ext_link=$(realpath --relative-to="$(dirname "$HOME/.urxvt/ext/font-size")" "$urxvt_ext")
else
urxvt_ext_link="$urxvt_ext"
fi
ln -s -f -v "$urxvt_ext_link" "$HOME/.urxvt/ext/font-size"
echo
echo "All done."