-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·81 lines (68 loc) · 1.87 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env zsh
########################
# setup.sh
#
# This script attempts to install Prezto and link my dotfiles to the correct places.
#
# Must be executed by zsh (NOT bash or sh)
# Assumes sudo is installed
#
# EXIT CODES:
# 1 - Not running linux
# 2 - Unable to determine which package manager to use
########################
setopt EXTENDED_GLOB
datetime=$(date +%Y%M%d%H%M%S)
# define some functions
setup_ubuntu () {
sudo apt update
sudo apt install -y git
}
# Check that we're running linux
platform=$(uname)
if [[ $platform != 'Linux' ]]; then
"Looks like you aren't running Linux. Support for other platforms is not yet complete."
exit 1
fi
# Attempt to determine which distro we're running
if [ -f /etc/os-release ]; then
source /etc/os-release
fi
# Automatically install git and dependencies, if possible
case $ID in
('ubuntu')
echo "Installing dependencies..."
setup_ubuntu
;;
(*)
echo 'Unable to automate setup.'
exit 2
;;
esac
# Backup existing dotfiles
echo "Backing up existing dotfiles to ~/dotfiles_old"
mkdir -p ~/dotfiles_old/$datetime
for dotfile in "${ZDOTDIR:-$HOME}"/dotfiles/runcoms/^README.md(.N); do
mv "${ZDOTDIR:-$HOME}/.${dotfile:t}" "$HOME/dotfiles_old/$datetime"
if [[ -h "$HOME/.${dotfile:t}" ]]; then
rm "$HOME/.${dotfile:t}"
fi
done
# Install Prezto
echo "Installing Prezto..."
if [[ -d "${ZDOTDIR:-$HOME}/.zprezto" ]]; then
echo "Prezto already installed."
else
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
fi
# Symlink dotfiles
echo "Linking dotfiles..."
for rcfile in "${ZDOTDIR:-$HOME}"/dotfiles/runcoms/^README.md(.N); do
ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done
# Set ZSH as default shell
echo "Setting ZSH as default shell..."
chsh -s $(which zsh)
# Success!
echo "DONE!"
exit 0