forked from erika-e/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_mac.sh
92 lines (70 loc) · 3.08 KB
/
setup_mac.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
setopt interactivecomments
# setup_mac.sh
# Without the setopt command zsh will sometimes give an error message about # not recognized
# Install homebrew
# https://brew.sh/
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install poetry
echo "Installing Poetry..."
/bin/bash -c "$(curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -)"
# Install git to get the brewfile
brew install git
# Install git credential manager
brew tap microsoft/git
brew install --cask git-credential-manager-core
## Configure git globally
echo "Configuring git name and email globally "
read "gitusername?Enter git user.name"
git config --global user.name $gitusername
read "gituseremail?Enter git user.email"
git config --global user.email $gituseremail
git config --global init.defaultBranch main
# Create a directory for repos
echo "Creating code directory"
mkdir -p code
cd code
# Remove the dotfiles repo if it already exists and restore from the source
if [ -d dotfiles ]; then rm -rf dotfiles ; fi
git clone https://github.com/erika-e/dotfiles.git
cd dotfiles
# Install dependencies from Brewfile
brew bundle install
# Pin python and dbt so they do not update automatically
brew pin python
brew pin dbt
# Install OH-MY-ZSH and auto suggestions
# https://ohmyz.sh/
# Check for and install oh-my-zsh if not already installed
if [ -d ~/.oh-my-zsh ];
then echo "oh-my, it's already installed" ;
else echo "oh-my-zsh not installed, installing..." && sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" ;
fi
# Check for and install zsh-autosuggestions
if [ -d ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions ] ;
then echo "zsh-autosuggestions is in the house" ;
else echo "Installing zsh-autosuggestions" && git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions ;
fi
# symlink custom alias files from dotfiles to the oh-my-zsh custom folder
ln -s ~/code/dotfiles/oh-my-zsh/*.zsh ~/.oh-my-zsh/custom
# Copy and source ~/.zshrc
cp .zshrc ~/.zshrc
source ~/.zshrc
# Install extensions for VSCode
# https://unix.stackexchange.com/questions/149726/how-to-parse-each-line-of-a-text-file-as-an-argument-to-a-command
# < file tr '\n' '\0' | xargs -0 -I{} command --option {} this shell script can do it
< vscode/extensions.txt tr '\n' '\0' | xargs -0 -I{} code --install-extension {}
# Create the VSCode settings file
touch "$HOME/Library/Application Support/Code/User/settings.json"
# Copy the template settings file to the system location
cp vscode/settings.json "$HOME/Library/Application Support/Code/User/settings.json"
# Set up a sandbox dbt project
cd ~/code
if [ -d jaffle_shop ]; then rm -rf jaffle_shop ; fi
git clone https://github.com/erika-e/jaffle_shop.git
# Create a dbt directory if it does not exist
mkdir -p ~/.dbt
# Create profiles.yml if it does not exist
touch ~/.dbt/profiles.yml
#Append the contents of the sample profiles.yml to the existing profiles.yml
cat dotfiles/dbt/profiles.yml >> ~/.dbt/profiles.yml