-
Notifications
You must be signed in to change notification settings - Fork 1
/
install
executable file
·143 lines (112 loc) · 4.31 KB
/
install
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
#!/usr/bin/env bash
set -e
function relink() {
if [[ -h "$1" ]]; then
echo "Relinking $1"
rm "$1"
ln -snf "$2" "$1"
elif [[ -e "$1" ]]; then
echo "Backing up $1"
mv -n "$1" "$1.old"
ln -snf "$2" "$1"
else
echo "Linking $1"
ln -snf "$2" "$1"
fi
}
echo "--- Linking files ---"
cd ~
relink .gitconfig ~/.dotfiles/git-config
relink .gitignore ~/.dotfiles/git-ignore-global
relink bin ~/.dotfiles/bin
relink .vimrc ~/.dotfiles/vimrc
relink .npmrc ~/.dotfiles/npmrc
relink .allowedsigners ~/.dotfiles/allowedsigners
# ---- Homebrew ----
echo "☕ Installing Homebrew"
if ! command -v brew &> /dev/null; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
chmod -R go-w "$(brew --prefix)/share"
else
echo "Homebrew already installed"
fi
echo "☕ Installing brew apps"
brew install git gh gpg vim wget ack tree highlight zsh-autosuggestions zsh-syntax-highlighting
# Install oh-my-zsh
echo "☕ Installing oh-my-zsh"
if [ ! -d "$HOME/.oh-my-zsh" ]; then
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
else
echo "oh-my-zsh already installed"
fi
relink .bash_profile ~/.dotfiles/bash_profile
relink .bashrc ~/.dotfiles/bashrc
relink .zshrc ~/.dotfiles/zshrc
source ~/.zshrc
# Download and install fonts
echo "☕ Installing fonts from: https://github.com/romkatv/powerlevel10k#get-started"
curl -fLo "$HOME/Library/Fonts/MesloLGS NF Regular.ttf" https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf
curl -fLo "$HOME/Library/Fonts/MesloLGS NF Bold.ttf" https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf
curl -fLo "$HOME/Library/Fonts/MesloLGS NF Italic.ttf" https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf
curl -fLo "$HOME/Library/Fonts/MesloLGS NF Bold Italic.ttf" https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf
echo "☕ Installing powerlevel theme, p10k"
if [ ! -d "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k" ]; then
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
else
echo "powerlevel10k already installed"
fi
echo "☕ restart terminal to configure the p10k theme"
# ---- GPG ----
mkdir -p ~/.gnupg
cd ~/.gnupg
relink gpg.conf ~/.dotfiles/gpgconf
relink gpg-agent.conf ~/.dotfiles/gpgagentconf
chown -R $(whoami) ~/.gnupg/
chmod 600 ~/.gnupg/*
chmod 700 ~/.gnupg
# ---- Volta ----
echo "☕ Installing Volta"
if ! command -v volta &> /dev/null; then
curl https://get.volta.sh | bash
volta install node
else
echo "Volta already installed"
fi
# --- SSH ---
echo "☕ Setting up SSH"
GIT_EMAIL=$(git config user.email)
gh auth login --hostname github.com
if [ ! -f ~/.ssh/id_ed25519 ]; then
echo "☕ No ssh key found, generating one"
ssh-keygen -t ed25519 -C "$GIT_EMAIL"
fi
echo "☕ Starting ssh-agent"
eval "$(ssh-agent -s)"
echo "☕ Adding ssh key to ssh-agent"
ssh-add -K ~/.ssh/id_ed25519
echo "$GIT_EMAIL $(cat ~/.ssh/id_ed25519.pub | cut -d ' ' -f 2)" > ~/.dotfiles/allowedsigners
echo "Host github.com
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519" > ~/.ssh/config
echo "☕ Refreshing GitHub login with ssh key"
gh auth refresh --hostname github.com --with-token < ~/.ssh/id_ed25519
echo "☕ Adding ssh key to GitHub account"
gh ssh-key add ~/.ssh/id_ed25519.pub --title "dotfiles"
# ---- VIM ----
echo "☕ Setting vim plugins"
mkdir -p ~/.vim ~/.vim/autoload ~/.vim/bundle ~/.vim/colors && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
cd ~/.vim/bundle
git clone https://github.com/pangloss/vim-javascript.git
git clone git://github.com/airblade/vim-gitgutter.git
git clone https://github.com/scrooloose/nerdtree.git
git clone git://github.com/ntpeters/vim-better-whitespace.git
git clone https://github.com/bling/vim-airline ~/.vim/bundle/vim-airline
git clone https://github.com/editorconfig/editorconfig-vim
mkdir $HOME/.vim/colors/
curl -LSso $HOME/.vim/colors/lucario.vim https://raw.githubusercontent.com/raphamorim/lucario/master/colors/lucario.vim
relink $HOME/.vim/colors/monokai.vim $HOME/.dotfiles/vim-colors/monokai.vim
echo "☕ ☕ ☕ Done! ☕ ☕ ☕"
cd $HOME