-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·75 lines (63 loc) · 1.52 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
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
set -e
# Make backup(s) if nessesary then link new config to $HOME
function link_file {
DIR="$2"
SOURCE="$1"
NAME="$(basename $SOURCE)"
TARGET="$HOME/${NAME/_/.}"
if [ -e "$TARGET" ]
then
BACKUP="$TARGET.bak"
if [ -e "$BACKUP" ]
then
COUNT=0
while [ -e "$BACKUP.$COUNT" ]; do let "COUNT += 1"; done
BACKUP="$BACKUP.$COUNT"
fi
mv "$TARGET" "$BACKUP"
echo "Backup file $BACKUP created."
fi
echo "Linking config file $TARGET."
ln -s "$DIR"/"$SOURCE" "$TARGET"
}
# Make backup(s) if nessesary then copy new config to $HOME
function copy_file {
SOURCE="$1"
NAME="$(basename $SOURCE)"
TARGET="$HOME/${NAME/_/.}"
if [ -e "$TARGET" ]
then
BACKUP="$TARGET.bak"
if [ -e "$BACKUP" ]
then
COUNT=0
while [ -e "$BACKUP.$COUNT" ]; do let "COUNT += 1"; done
BACKUP="$BACKUP.$COUNT"
fi
mv "$TARGET" "$BACKUP"
echo "Backup file $BACKUP created."
fi
echo "Creating config file $TARGET."
cp -r "$SOURCE" "$TARGET"
}
CWD="$(dirname $0)"
PWD=$(pwd)
DOTFILES="
_aliases
_bashrc
_screenrc
_shell-fu.bashrc
_vimrc
_z.sh
"
for DOTFILE in $(echo "$DOTFILES")
do
if [ -d .git ]; then
link_file "$DOTFILE" "$PWD"
else
wget https://github.com/jokajak/dotfiles/raw/master/"$DOTFILE" \
-O "$CWD"/"$DOTFILE" --quiet --no-check-certificate
copy_file "$DOTFILE"
fi
done