forked from MikeMcQuaid/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-dotfiles.sh
executable file
·43 lines (36 loc) · 1.1 KB
/
install-dotfiles.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
#!/bin/sh
# Install all dotfiles into the home directory
DOTFILESDIRREL=$(dirname $0)
cd $DOTFILESDIRREL
DOTFILESDIR=$(pwd -P)
SCRIPTNAME=$(basename $0)
[ $(uname -s) = "Darwin" ] && export OSX=1 && export UNIX=1
[ $(uname -s) = "Linux" ] && export LINUX=1 && export UNIX=1
uname -s | grep -q "_NT-" && export WINDOWS=1
for DOTFILE in *; do
HOMEFILE="$HOME/.$DOTFILE"
[ -d $DOTFILE ] && DOTFILE="$DOTFILE/"
DIRFILE="$DOTFILESDIR/$DOTFILE"
echo $DOTFILE | egrep -q '(dotfiles|\.txt|\.md)' && continue
# Don't install some files unless you're also called Mike.
if echo $USER | grep -vq 'mike'
then
echo $DOTFILE | grep -q 'gitconfig-user' && continue
echo $DOTFILE | grep -q 'ssh' && continue
echo $DOTFILE | grep -q 'brew-cleanup-installed' && continue
fi
echo $DOTFILE | grep -q '\.sh' \
&& HOMEFILE="$HOME/.$(echo $DOTFILE | sed -e 's/\.sh//')"
if [ $UNIX ]
then
if [ -L "$HOMEFILE" ] && ! [ -d $DOTFILE ]
then
ln -sfv "$DIRFILE" "$HOMEFILE"
else
rm -rv "$HOMEFILE"
ln -sv "$DIRFILE" "$HOMEFILE"
fi
else
cp -rv "$DIRFILE" "$HOMEFILE"
fi
done