-
Notifications
You must be signed in to change notification settings - Fork 8
/
laptop.sh
executable file
·139 lines (113 loc) · 3.25 KB
/
laptop.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
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
#!/bin/bash
# ./laptop.sh
# - symlinks for dotfiles to `$HOME`
# - text editor (Neovim)
# - programming language runtimes (Go, Ruby, Node)
# - language servers (HTML, SQL)
# - CLIs (AWS, GitHub, Render)
# This script can be safely run multiple times.
# Tested with macOS Sonoma (14.4) on arm64 (Apple Silicon)
set -eux
# Symlinks
(
# Git
ln -sf "$PWD/git/gitconfig" "$HOME/.gitconfig"
ln -sf "$PWD/git/gitignore" "$HOME/.gitignore"
# Ruby
mkdir -p "$HOME/.bundle"
ln -sf "$PWD/ruby/bundle/config" "$HOME/.bundle/config"
ln -sf "$PWD/ruby/gemrc" "$HOME/.gemrc"
ln -sf "$PWD/ruby/irbrc" "$HOME/.irbrc"
ln -sf "$PWD/ruby/rspec" "$HOME/.rspec"
# Shell
mkdir -p "$HOME/.config/bat"
ln -sf "$PWD/shell/bat" "$HOME/.config/bat/config"
ln -sf "$PWD/shell/hushlogin" "$HOME/.hushlogin"
mkdir -p "$HOME/.config/kitty"
ln -sf "$PWD/shell/kitty.conf" "$HOME/.config/kitty/kitty.conf"
ln -sf "$PWD/shell/psqlrc" "$HOME/.psqlrc"
mkdir -p "$HOME/.ssh"
ln -sf "$PWD/shell/ssh" "$HOME/.ssh/config"
ln -sf "$PWD/shell/tmux.conf" "$HOME/.tmux.conf"
ln -sf "$PWD/shell/zshrc" "$HOME/.zshrc"
# Vim
mkdir -p "$HOME/.config/nvim"
ln -sf "$PWD/vim/init.lua" "$HOME/.config/nvim/init.lua"
)
# Homebrew
BREW="/opt/homebrew"
if [ ! -d "$BREW" ]; then
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
fi
export PATH="$BREW/bin:$PATH"
brew analytics off
brew update-reset
brew bundle --no-lock --file=- <<EOF
tap "CrunchyData/brew"
tap "oven-sh/bun"
brew "awscli"
brew "bat"
brew "CrunchyData/brew/cb"
brew "fzf"
brew "gh"
brew "git"
brew "go"
brew "jq"
brew "lua-language-server"
brew "neovim"
brew "node"
brew "oven-sh/bun/bun"
brew "pgformatter"
brew "prettier"
brew "shellcheck"
brew "stylua"
brew "the_silver_searcher"
brew "tldr"
brew "tmux"
brew "tree"
brew "tree-sitter"
brew "watch"
brew "zsh"
# https://github.com/rbenv/ruby-build/wiki
brew "gmp"
brew "libyaml"
brew "openssl@3"
brew "readline"
brew "ruby-build"
brew "rust" # https://github.com/ruby/ruby/blob/master/doc/yjit/yjit.md
EOF
brew upgrade
brew autoremove
brew cleanup
# Shell
if [ ! -d "/Applications/kitty.app" ]; then
curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin
fi
if [ "$(command -v zsh)" != "$BREW/bin/zsh" ] ; then
sudo chown -R "$(whoami)" "$BREW/share/zsh" "$BREW/share/zsh/site-functions"
chmod u+w "$BREW/share/zsh" "$BREW/share/zsh/site-functions"
shellpath="$(command -v zsh)"
if ! grep "$shellpath" /etc/shells > /dev/null 2>&1 ; then
sudo sh -c "echo $shellpath >> /etc/shells"
fi
chsh -s "$shellpath"
fi
# Go
if ! command -v godoc &> /dev/null; then
go install golang.org/x/tools/cmd/godoc@latest
fi
# Ruby
v="3.3.2"
if [ ! -d "$HOME/.rubies/ruby-$v" ]; then
RUBY_CONFIGURE_OPTS="--enable-yjit --with-openssl-dir=$(brew --prefix openssl@3)" ruby-build "$v" "$HOME/.rubies/ruby-$v"
fi
# HTML
npm i -g vscode-langservers-extracted
# NeoVim with Packer
PACKER_DIR="$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim"
if [ ! -d "$PACKER_DIR" ]; then
git clone --depth 1 https://github.com/wbthomason/packer.nvim "$PACKER_DIR"
fi
nvim --headless -c 'packadd packer.nvim' -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
# Treesitter
nvim --headless -c 'packadd packer.nvim' -c 'TSUpdateSync' -c 'quitall'