Skip to content

Instantly share code, notes, and snippets.

@phuctm97
Last active April 17, 2020 08:55
Show Gist options
  • Save phuctm97/9506335659ec4897464ec3cee9d55df4 to your computer and use it in GitHub Desktop.
Save phuctm97/9506335659ec4897464ec3cee9d55df4 to your computer and use it in GitHub Desktop.
💻 Install macOS Catalina
#!/bin/bash
# Enable sudo Touch ID authentication.
sudo python <<HEREDOC
import re
pam_cfg = '/etc/pam.d/sudo'
auth_re = re.compile(r'^auth\s+sufficient\s+')
tid_re = re.compile(r'^auth\s+sufficient\s+pam_tid.so')
def main():
with open(pam_cfg, 'r') as f:
contents = f.readlines()
index = -1
template = 'auth sufficient '
for i, line in enumerate(contents):
if tid_re.match(line) != None:
return
m = auth_re.match(line)
if m != None:
index = i
template = m.group(0)
contents.insert(index + 1, template + 'pam_tid.so\n')
with open(pam_cfg, 'w') as f:
f.write(''.join(contents))
main()
HEREDOC
# Install XCode Command Line Tools.
xcode-select --install &> /dev/null
# Wait until XCode Command Line Tools installation finished.
until $(xcode-select --print-path &> /dev/null); do
sleep 5;
done
# Install Homebrew.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Fix permission issues with ZSH.
CWD=$(pwd)
cd /usr/local/share
sudo chmod -R 755 zsh
cd $CWD
# Install Antigen.
CWD=$(pwd)
cd /usr/local/share
mkdir antigen
sudo chmod -R 755 antigen
cd antigen
curl -L git.io/antigen > antigen.zsh
cd $CWD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment