-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
56 lines (46 loc) · 1.33 KB
/
setup.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
#!/bin/zsh
# Make sure oh-my-zsh is installed
[ ! -d ~/.oh-my-zsh ] && sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
if [[ -n $SPIN ]]; then
DOOT_DIR="$HOME/dotfiles/doots"
else
DOOT_DIR="$HOME/projects/dotfiles/doots"
fi
# Setup Dotfiles
function setupDotfiles() {
echo "Installing .gitconfig and .aliases for $1..."
vimrcFile=".vimrc"
if [[ $1 == 'local' ]]; then
gitConfigFile=".gitconfig.personal"
aliasFile=".aliases.personal"
else
gitConfigFile=".gitconfig.work"
aliasFile=".aliases.work"
fi
cp "$DOOT_DIR/$gitConfigFile" $HOME/".gitconfig"
cp "$DOOT_DIR/$aliasFile" $HOME/".aliases"
cp "$DOOT_DIR/$vimrcFile" $HOME/".vimrc"
if [[ -d $DOOT_DIR ]] && [[ ! -L $DOOT_DIR ]]; then
for doot in $(ls -ap $DOOT_DIR | grep -v /); do
dootname="$(basename "$doot")"
if [[ $dootname =~ '.gitconfig' || $dootname =~ '.aliases' ]]; then
continue
fi
echo "Installing $dootname..."
target=~/"$dootname"
[[ -f "$target" ]] && mv "$target" "$target.bak"
cp "$DOOT_DIR/$dootname" $HOME/"$dootname"
done
else
echo "Can't find directory: $DOOT_DIR."
fi
}
# Personal or Work?
if [[ $(uname -m) == 'arm64' || -n $SPIN ]]; then
setupDotfiles 'work'
else
setupDotfiles 'local'
fi
if [[ ! "$SPIN" ]]; then
exec zsh
fi