-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·128 lines (102 loc) · 3.96 KB
/
setup
File metadata and controls
executable file
·128 lines (102 loc) · 3.96 KB
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
#!/bin/bash
set -e
cd "$(dirname "$0")"
echo() { printf "\n\033[36m%s\033[0m\n" "$*"; }
install_if_missing() {
local cmd=$1
local installer=$2
command -v "$cmd" >/dev/null || eval "$installer"
}
clone_if_missing() {
local dir=$1
shift
[[ -e "$dir" ]] || git clone "$@" "$dir"
}
run_if_exists() {
local file=$1
if [[ -e "$file" ]]; then
"$file"
else
echo "Warning: $file not found, skipping"
fi
}
run_command_if_file_exists() {
local file="$1"
shift
[[ -e "$file" ]] && "$@"
}
OS="$(uname -s)"
IS_MAC=false
[[ "$OS" == "Darwin" ]] && IS_MAC=true
if $IS_MAC; then
sudo -v
while true; do sudo -n true; sleep 60; kill -0 "$" || exit; done 2>/dev/null &
echo "Installing core tools"
sudo xcode-select --install 2>/dev/null || true
install_if_missing bun 'curl -s "https://bun.sh/install" | bash'
install_if_missing brew '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
echo "Installing apps"
brew analytics off
brew install stow raycast iterm2 arc karabiner-elements visual-studio-code
run_command_if_file_exists "./brew/Brewfile" brew bundle --file=./brew/Brewfile
run_command_if_file_exists "./brew/mixed-in-key.rb" brew install --cask ./brew/mixed-in-key.rb
run_command_if_file_exists "/Applications/KeeWeb.app" sudo chown -R root /Applications/KeeWeb.app
[[ ! -f "$HOME/.ssh/id_rsa.pub" ]] && run_command_if_file_exists "$HOME/.ssh/id_rsa" ssh-keygen -y -f $HOME/.ssh/id_rsa > $HOME/.ssh/id_rsa.pub
[[ ! -f "$DOTFILESPATH/maven/.m2/settings.xml" ]] && envify SIGNING_PASSWORD NEXUS_PASSWORD && envsubst < "$DOTFILESPATH/maven/.m2/settings.template.xml" > "$DOTFILESPATH/maven/.m2/settings.xml"
echo "Applying settings"
run_if_exists ./.macos
run_if_exists ./duti/setfiledefaults
echo "Setting up Python"
sudo ln -sf /opt/homebrew/bin/python3 /usr/local/bin/python
sudo ln -sf /opt/homebrew/bin/python3 /usr/local/bin/python3
sudo ln -sf /opt/homebrew/bin/pip3 /usr/local/bin/pip
sudo ln -sf /opt/homebrew/bin/pip3 /usr/local/bin/pip3
run_command_if_file_exists "$HOME/Projects/private/dotfiles" ln -sf "$HOME/Projects/private/dotfiles" "$HOME/dotfiles"
else
ln -sf /usr/bin/python3 /usr/local/bin/python
fi
[[ -d "$HOME/.sdkman" ]] || curl -s "https://get.sdkman.io" | bash
echo "Setting up Java"
for version in 21.0.8-tem 25-tem; do
bash -c "source '$HOME/.sdkman/bin/sdkman-init.sh' && sdk install java $version"
done
bash -c "source '$HOME/.sdkman/bin/sdkman-init.sh' && sdk default java 21.0.8-tem"
echo "Preparing Vim before dotfiles setup"
clone_if_missing "$HOME/.vim_runtime" "https://github.com/amix/vimrc.git" --depth=1
echo "Setting up dotfiles"
run_if_exists ./stowsetup && source "$HOME/.bashrc"
echo "Installing Node packages"
npm install -g eslint vue yarn @cometix/ccline
echo "Setting up terminal"
clone_if_missing "$HOME/.tmux" "https://github.com/gpakosz/.tmux.git"
clone_if_missing "${ZDOTDIR:-$HOME}/.zprezto" "https://github.com/sorin-ionescu/prezto.git" --recursive
clone_if_missing "$HOME/.zgen" "https://github.com/tarjoilija/zgen.git"
[[ "$SHELL" != "/bin/zsh" ]] && chsh -s /bin/zsh
echo "Setting up Vim"
sh "$HOME/.vim_runtime/install_awesome_vimrc.sh"
mkdir -p "$VIM_PLUGINS_DIR"
for plugin in \
Glench/Vim-Jinja2-Syntax \
neoclide/coc.nvim \
ap/vim-css-color \
benmills/vimux \
editorconfig/editorconfig-vim \
jceb/vim-orgmode \
junegunn/fzf.vim \
mattn/emmet-vim \
scrooloose/nerdcommenter \
tmux-plugins/vim-tmux-focus-events \
tomlion/vim-solidity \
tpope/vim-dispatch \
vim-airline/vim-airline
do
name=$(basename "$plugin")
clone_if_missing "$VIM_PLUGINS_DIR/$name" "https://github.com/$plugin.git"
done
if $IS_MAC; then
echo "Building CoC plugin"
cd "$VIM_PLUGINS_DIR/coc.nvim" && npm ci
echo "Installing CoC extensions"
vim -c 'CocInstall coc-clangd coc-tsserver coc-python coc-json coc-css coc-html' -c 'qa'
fi
echo "Setup complete! Restart your terminal."