-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·122 lines (105 loc) · 3.71 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/sh
# Add different instructions for Linux/MacOSX
case "$(uname -s)" in
Linux*) OS=Linux;;
Darwin*) OS=Mac;;
*) echo "Unknown OS $(uname -s), quitting install" && exit 1;;
esac
CONFIG="$HOME/.config"
# Ask for the administrator password upfront
echo "Sudo password is needed later on. Asking now so installation can proceed unattended"
sudo -v
# Keep-alive: update existing `sudo` time stamp until finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Make sure we start in the home directory
cd "$HOME" || exit 1
# Linux needs some things installed first
if [ "$OS" = "Linux" ]; then
echo 'Updating Linux system files ...'
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install ack build-essential curl file git vim-nox wget zsh
which zsh | sudo tee -a /etc/shells
chsh -s "$(which zsh)"
fi
# Install, or update, homebrew
if [ ! "$(which brew)" ]; then
echo 'Installing Homebrew ...'
if [ "$OS" = "Mac" ]; then
tempd=$(mktemp -d)
curl -sSL -o "$tempd"/brew.pkg https://github.com/Homebrew/brew/releases/download/5.3.3/Homebrew-4.3.3.pkg "$tempd"/brew.pkg
sudo installer -pkg "$tempd"/brew.pkg -target /
else
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# Turn off brew analytics as most of the time this is a work machine
brew analytics off
# Install some supporting software
if [ "$OS" = "Mac" ]; then
brew install --cask docker google-chrome iterm2 visual-studio-code
brew install trash git ack wget
# Instal divvy window manager
open -a "Google Chrome" "http://itunes.apple.com/app/id413857545"
fi
brew install bat prettyping
brew cleanup
else
echo 'Updating Homebrew ...'
brew update
brew upgrade
fi
# Install powerline fonts
if [ "$OS" = "Mac" ]; then
if [ ! -f "$HOME/Library/Fonts/Inconsolata-Regular.ttf" ]; then
echo 'Installing Inconsolata ...'
curl -sSL -o "$HOME/Library/Fonts/Inconsolata-Regular.ttf" https://github.com/google/fonts/raw/main/ofl/inconsolata/static/Inconsolata-Regular.ttf
fi
if [ ! -f "$HOME/Library/Fonts/Inconsolata for Powerline.otf" ]; then
echo 'Installing Inconsolata for Powerline ...'
curl -sSL -o "$HOME/Library/Fonts/Inconsolata for Powerline.otf" https://github.com/powerline/fonts/raw/master/Inconsolata/Inconsolata%20for%20Powerline.otf
fi
fi
# Clone, or update, the repo
if [ ! -d "$CONFIG" ]; then
echo 'Getting the config files from GitHub ...'
git clone --recursive https://github.com/eddiemonge/DOT.config.git "$CONFIG"
builtin cd "$CONFIG" && { \
git submodule update --init --recursive
git remote rename origin origin-http \
builtin cd -; \
}
else
builtin cd "$CONFIG" && { \
git submodule update --init --recursive
git pull --rebase origin-http main ; \
git submodule update ; \
builtin cd -; \
}
fi
# Set where zsh gets it's config file from
if [ ! -f "$HOME/.zshenv" ]; then
echo 'Setting up zsh env ...'
ln -s "$CONFIG/zsh/zshenv" "$HOME/.zshenv"
fi
. "$HOME/.zshenv"
# Source zsh files
. "$CONFIG/zsh/.zshrc"
# Setup Git Author info
if [ ! -f "$CONFIG/git/author" ]; then
if [ "$OS" = "Mac" ]; then
cp "$CONFIG/git/author.sample" "$CONFIG/git/author"
code "$CONFIG/git/author"
elif [ "$OS" = "Linux" ]; then
echo 'To setup your git author information, copy and edit the sample'
echo "cp $CONFIG/git/author.sample $CONFIG/git/author"
fi
fi
# Run the OS customizations
# TODO: Should they be installed based on MacOS version?
if [ "$OS" = "Mac" ]; then
echo 'Customizing OSX ...'
sh "$CONFIG/osx/settings.sh"
fi
echo 'All done!'
echo 'Do not forget to configure ssh:'
echo 'ssh-keygen -t ed25519 -C "[email protected]"'