-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-macos-macports
executable file
·151 lines (118 loc) · 5.8 KB
/
setup-macos-macports
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
#check for XCode install
xcodeapp="/Applications/Xcode.app"
if [ -e "$xcodeapp" ]
then
echo "XCode is already installed, continuing setup."
else
echo "Xcode needs to be installed before installing macports, you can get it from the App Store. Exiting setup script."
exit 0
fi
echo "Accept Xcode license if not already done (needs sudo)"
sudo xcodebuild -license accept
#echo "Installing Command Line Tools"
#`pwd`/misc/install_cmd_line_tools.sh
#echo "Setting Command Line Tools as default (needs sudo)"
#sudo xcode-select --switch "/Library/Developer/CommandLineTools"
echo "Downloading and installing latest macports release based on OS running (install needs sudo)"
osx_vers=$(sw_vers -productVersion | awk -F "." '{print $2}')
if [[ "$osx_vers" -le 12 ]]; then
echo "This script won't work for macOS 10.12 and below"
exit 0
fi
if [[ "$osx_vers" -eq 13 ]]; then
#Download macOS 10.13 MacPorts package
/usr/bin/curl -s -o /tmp/macports.pkg https://distfiles.macports.org/MacPorts/MacPorts-2.6.1-10.13-HighSierra.pkg
#Install MacPorts for macOS 10.13
sudo /usr/sbin/installer -pkg /tmp/macports.pkg -target /
#Delete tmp file
/bin/rm /tmp/macports.pkg
fi
if [[ "$osx_vers" -eq 14 ]]; then
#Download macOS 10.14 MacPorts package
/usr/bin/curl -s -o /tmp/macports.pkg https://distfiles.macports.org/MacPorts/MacPorts-2.6.1-10.14-Mojave.pkg
#Install MacPorts for macOS 10.14
sudo /usr/sbin/installer -pkg /tmp/macports.pkg -target /
#Delete tmp file
/bin/rm /tmp/macports.pkg
fi
if [[ "$osx_vers" -eq 15 ]]; then
#Download macOS 10.15 MacPorts package
/usr/bin/curl -s -o /tmp/macports.pkg https://github.com/macports/macports-base/releases/download/v2.6.1/MacPorts-2.6.1-10.15-Catalina.pkg
#Install MacPorts for macOS 10.15
sudo /usr/sbin/installer -pkg /tmp/macports.pkg -target /
#Delete tmp file
/bin/rm /tmp/macports.pkg
fi
echo "Updating macports definitions (needs sudo)"
sudo /opt/local/bin/port selfupdate
sudo /opt/local/bin/port upgrade outdated
echo "Installing some packages (with dependencies)"
sudo /opt/local/bin/port -q -N install zsh mosh tmux mas mtr pwgen youtube-dl htop glances git hub
echo "Selecting python27 as default python (needed after)"
sudo /opt/local/bin/port -q select --set python python27
sudo /opt/local/bin/port -q select --set python2 python27
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 Source Code Pro font"
#/usr/bin/curl -s -o /tmp/source-code-pro.zip https://www.fontsquirrel.com/fonts/download/source-code-pro
#/usr/bin/unzip -qq /tmp/source-code-pro.zip -d ~/Library/Fonts/
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 macports version)"
ln -s `pwd`/zshrc/zshrc-macports ~/.zshrc
echo "Adding aliases for bins (and creating ~/bin is 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 macports as default shell and adding it to /etc/shells (needs sudo)"
sudo sh -c 'echo /opt/local/bin/zsh >>/etc/shells'
sudo chpass -s '/opt/local/bin/zsh' $USER
echo "Setup done, exiting. Open a new terminal to see changes."
exit 0