-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·92 lines (79 loc) · 2.13 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env bash
{ # This ensures the entire script is downloaded.
set -eo pipefail
basedir="$HOME/go/src/github.com/tylerwince/dotfiles"
repourl="git://github.com/tylerwince/dotfiles.git"
function symlink() {
src="$1"
dest="$2"
if [ -e "$dest" ]; then
if [ -L "$dest" ]; then
# Already symlinked -- I'll assume correctly.
return
else
# Rename files with a ".bak" extension.
echo "$dest already exists, renaming to $dest.bak"
backup="$dest.bak"
if [ -e "$backup" ]; then
echo "Error: "$backup" already exists. Please delete or rename it."
exit 1
fi
mv -v "$dest" "$backup"
fi
fi
ln -sf "$src" "$dest"
}
if [ ! -d $HOME/.oh-my-zsh ]; then
echo "Setting up oh-my-zsh..."
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
fi
if ! which git >/dev/null ; then
echo "Error: git is not installed"
exit 1
fi
if [ -d "$basedir/.git" ]; then
echo "Updating dotfiles using existing git..."
cd "$basedir"
git pull --quiet --rebase origin master || exit 1
else
echo "Checking out dotfiles using git..."
rm -rf "$basedir"
git clone --quiet --depth=1 "$repourl" "$basedir"
fi
cd "$basedir"
echo "Creating symlinks..."
for path in .* ; do
case "$path" in
.|..|.git)
continue
;;
*)
symlink "$basedir/$path" "$HOME/$path"
;;
esac
done
if which tmux >/dev/null 2>&1 ; then
echo "Setting up tmux..."
tpm="$HOME/.tmux/plugins/tpm"
if [ -e "$tpm" ]; then
pushd "$tpm" >/dev/null
git pull -q origin master
popd >/dev/null
else
git clone -q https://github.com/tmux-plugins/tpm "$HOME/.tmux/plugins/tpm"
fi
$tpm/scripts/install_plugins.sh >/dev/null
$tpm/scripts/clean_plugins.sh >/dev/null
$tpm/scripts/update_plugin.sh >/dev/null
else
echo "Skipping tmux setup because tmux isn't installed."
fi
postinstall="$HOME/.postinstall"
if [ -e "$postinstall" ]; then
echo "Running post-install..."
. "$postinstall"
else
echo "No post install script found. Optionally create one at $postinstall"
fi
echo "Done."
} # This ensures the entire script is downloaded.