-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-env
executable file
·115 lines (95 loc) · 3.07 KB
/
setup-env
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
#!/bin/bash
OS=$(uname -s)
cd "$HOME"
if [ -f ".gitconfig" ]; then
echo ".gitconfig already exists"
exit 1
fi
if [ "$OS" == "Linux" ]; then
sudo apt-get update && sudo apt-get install -y git
fi
## Git Config
git clone https://github.com/alexbarnsley/dotfiles.git
find "$HOME/dotfiles" -name ".*" -not -name ".zshrc" -exec mv {} "$HOME" \;
git remote set-url origin [email protected]:alexbarnsley/dotfiles.git
ALIASES_FILE=""
if [ -f ".bash_aliases" ]; then
ALIASES_FILE=".bash_aliases"
elif [ -f ".bashrc" ]; then
ALIASES_FILE=".bashrc"
elif [ -f ".profile" ]; then
ALIASES_FILE=".profile"
else
if [ "$OS" == "Linux" ]; then
echo "No file for aliases"
exit 1
else
touch .bash_aliases
ALIASES_FILE=".bash_aliases"
fi
fi
ALIAS_EXISTS=$(egrep "^## Pre-loaded Aliases ##$" "$ALIASES_FILE")
if [ -z "$ALIAS_EXISTS" ]; then
echo '## Pre-loaded Aliases ##' >> "$ALIASES_FILE"
cat dotfiles/bash_aliases >> "$ALIASES_FILE"
fi
if [ "$OS" == "Darwin" ]; then
xcode-select --install
## Install Homebrew
brew -v &>/dev/null || INSTALL_BREW="Y"
if [ "$INSTALL_BREW" == "Y" ]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi
## Install wget
wget --version &>/dev/null || INSTALL_WGET="Y"
if [ "$INSTALL_WGET" == "Y" ]; then
brew install wget
fi
## Install Powerline Fonts
git clone https://github.com/powerline/fonts.git --depth=1 "$HOME/powerline-fonts"
cd "$HOME/powerline-fonts"
./install.sh
cd "$HOME"
rm -rf "$HOME/powerline-fonts"
## Oh My Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
mv "$HOME/dotfiles/.zshrc" "$HOME/.zshrc"
## Oh My Zsh theme
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "$HOME/.oh-my-zsh/custom/themes/powerlevel10k"
fi
## Node Installation
if [ "$OS" == "Linux" ]; then
LINUX_FLAVOUR=$(cat /etc/os-release | egrep "^ID_LIKE=" | egrep -o "\w+$")
if [ -z "$LINUX_FLAVOUR" ]; then
LINUX_FLAVOUR=$(cat /etc/os-release | egrep "^ID=" | egrep -o "\w+$")
fi
if [ -z "$LINUX_FLAVOUR" ]; then
echo "Could not determine Linux flavour"
exit 1
fi
if [ "$LINUX_FLAVOUR" == "debian" ]; then
## Install NodeJS & NPM
NODE_VERSION=$((node -v | egrep -o "[0-9]+" | head -1) 2>/dev/null || echo 0)
if [ "$NODE_VERSION" -lt "11" ]; then
curl -sL https://deb.nodesource.com/setup_11.x | sudo bash -
sudo apt-get update && sudo apt-get install -y nodejs
fi
## Install Yarn
YARN_VERSION=$(yarn -v 2>/dev/null)
if [ -z "$YARN_VERSION" ]; then
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install -y yarn
fi
sudo su "$USER"
elif [ "$LINUX_FLAVOUR" == "arch" ]; then
sudo pacman -Syu nodejs npm yarn
fi
## Add global yarn package
yarn global add n
fi
## Make ssh folder
if [ ! -d "$HOME/.ssh" ]; then
mkdir "$HOME/.ssh" && chmod 600 "$HOME/.ssh"
fi
rm -rf "$HOME/dotfiles"