-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-macos-brew
executable file
·115 lines (90 loc) · 3.95 KB
/
setup-macos-brew
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
#check for XCode install
xcodeapp="/Applications/Xcode.app"
if [ -e "$xcodeapp" ]
then
echo "XCode is already installed, continuing setup."
else
while true; do
read -p "Xcode is not installed. Although you won't need it with brew, do you want to continue? [y/n] " yn
case $yn in
[Yy]* ) echo "Continuing setup"; break;;
[Nn]* ) exit;;
* ) echo "Please answer with yes or no.";;
esac
done
fi
#echo "Installing Command Line Tools (needed for brew)"
#`pwd`/misc/install_cmd_line_tools.sh
echo "Setting Command Line Tools as default (needs sudo)"
sudo xcode-select --switch "/Library/Developer/CommandLineTools"
echo "Installing latest homebrew"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo "Updating brew's formulae"
brew update
echo "Installing some packages"
brew install zsh mosh tmux mas mtr pwgen youtube-dl subnetcalc htop glances tldr git hub
#brew cask install iterm2
#brew tap caskroom/fonts
#brew cask install font-source-code-pro
echo "Installing latest iTerm (needs sudo)"
#curl down xml with http links
/usr/bin/curl -s https://www.iterm2.com/appcasts/final.xml |/usr/bin/tail -8 |/usr/bin/grep http >> /tmp/tmp_url_iterm.txt
# get the exact url from that xml
/usr/bin/awk -F'[""]' '{print $2}' /tmp/tmp_url_iterm.txt >> /tmp/dl_url_iterm.txt
# curl down the zip file
/usr/bin/xargs -n 1 /usr/bin/curl -o /tmp/iTerm.zip < /tmp/dl_url_iterm.txt
# unzip the file into /Applications
sudo /usr/bin/unzip -qo -d /Applications /tmp/iTerm.zip
#clean up
/bin/rm -rf /tmp/iTerm.zip
/bin/rm -rf /tmp/tmp_url_iterm.txt
/bin/rm -Rf /tmp/dl_url_iterm.txt
echo "Installing Powerline patched fonts"
# clone
git clone https://github.com/powerline/fonts.git --depth=1 /tmp/fonts
# install
/tmp/fonts/install.sh
# clean-up a bit
rm -rf /tmp/fonts
echo "Installing Oh my ZSH"
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
echo "Installing zsh plugins & theme"
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions.git ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
git clone https://github.com/denysdovhan/spaceship-prompt.git ~/.oh-my-zsh/custom/themes/spaceship-prompt
ln -s ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting.plugin.zsh
ln -s ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions.plugin.zsh
ln -s ~/.oh-my-zsh/custom/themes/spaceship-prompt/spaceship.zsh-theme ~/.oh-my-zsh/custom/themes/spaceship.zsh-theme
echo "Setup configuration files"
rm ~/.zshrc ~/.zshenv ~/.aliases ~/.gitconfig ~/.gitignore ~/.spaceship_options ~/.tmux.conf
config_files=`pwd`/config/*
for file in $config_files; do
config=$(basename $file)
echo "Creating symlink for .$config"
ln -s $file ~/.$config
done
echo "Creating symlink for .zshrc (the brew version)"
ln -s `pwd`/zshrc/zshrc-brew ~/.zshrc
echo "Adding aliases for bins (and creating ~/bin if it does not exist)"
mkdir -p ~/bin/
bin_aliases=`pwd`/bins/*
for bins in $bin_aliases; do
bin=$(basename $bins)
echo "Creating symlink for $bin"
ln -s $bins ~/bin/$bin
done
echo "Setup vim theme"
mkdir -p ~/.vim/colors
vim_theme=`pwd`/themes
ln -s $vim_theme/dracula.vim ~/.vim/colors/dracula.vim
#echo "Installing SpaceVim"
#curl -sLf https://spacevim.org/install.sh | bash
echo "Setting iTerm2 preferences folder..."
defaults write com.googlecode.iterm2 "PrefsCustomFolder" -string "`pwd`/iterm"
defaults write com.googlecode.iterm2 "LoadPrefsFromCustomFolder" -bool true
echo "Setting zsh from brew as default shell, and adding it to /etc/shells (needs sudo)"
sudo tee -a /etc/shells <<< "/usr/local/bin/zsh"
sudo chpass -s '/usr/local/bin/zsh' $USER
echo "Setup done, exiting. Open a new terminal to see changes."
exit 0