-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·178 lines (142 loc) · 5.12 KB
/
setup.sh
File metadata and controls
executable file
·178 lines (142 loc) · 5.12 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/bash
message() {
# tput: sets terminal capabilities
# setaf: sets foreground color (set ansi foreground color)
# sgr0: sets terminal to default color
content="$2";
if [ "$1" = "info" ]; then
color="$(tput setaf 3)"
content="$content..."
elif [ "$1" = "error" ]; then
color="$(tput setaf 1)"
elif [ "$1" = "success" ]; then
color="$(tput setaf 2)"
tput cuu1 && tput el
fi
printf "%s%s%s\n" "$color" "$content" "$(tput sgr0)"
if [ "$1" = "error" ]; then
exit 1
fi
}
homebrew() {
# taken from:
# https://github.com/denolfe/dotfiles/blob/master/macos/setup-homebrew.sh
if [ -f "`which brew`" ]; then
message "success" "Homebrew found, skipping installation"
return 0
fi
message "info" "Installing Homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> $HOME/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
brew update
brew upgrade
brew install mas
brew cleanup
message "success" "Homebrew installed"
}
core() {
message "info" "installing core tools"
which kitty || curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin
brew install tmux
brew install hledger
brew install zoxide
brew install fzf
brew install git-delta
brew install neovim
brew install npm
brew install sd
brew install eza
brew install bat
brew install ripgrep
brew install fd
brew install zsh-autosuggestions
brew install zsh-syntax-highlighting
brew install mos
# yazi
brew install yazi ffmpeg sevenzip jq poppler fd ripgrep fzf zoxide imagemagick font-symbols-only-nerd-font
brew cleanup
# tpm
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# asdf
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0
message "success" "core tools installed"
}
setup_links() {
message "info" "setting up links"
mkdir -p ~/.config
# `-d` checks if dir exists
[ -d ~/.config/tmux ] || ln -s $(PWD)/tmux ~/.config/
[ -d ~/.config/zsh ] || ln -s $(PWD)/zsh ~/.config/
[ -d ~/.config/kitty ] || ln -s $(PWD)/kitty ~/.config/
[ -d ~/.config/nvim ] || ln -s $(PWD)/nvim ~/.config/
[ -d ~/.config/gh-dash ] || ln -s $(PWD)/gh-dash ~/.config/
[ -d ~/.config/git ] || ln -s $(PWD)/git ~/.config/
# `-f` checks if file exists
[ -f ~/.gitconfig ] || ln -s $(PWD)/gitconfig ~/.gitconfig
[ -f ~/.zshrc ] || ln -s $(PWD)/zsh/zshrc ~/.zshrc
[ -f ~/.tmux.conf ] || ln -s $(PWD)/tmux/tmux.conf ~/.tmux.conf
[ -f ~/.config/karabiner/karabiner.json ] || ln -s $(PWD)/karabiner/karabiner.json ~/.config/karabiner/karabiner.json
[ -f ~/.config/karabiner/assets/complex_modifications/custom-capslock.json ] || ln -s $(PWD)/karabiner/custom-capslock.json ~/.config/karabiner/assets/complex_modifications/custom-capslock.json
[ -f ~/.config/karabiner/assets/complex_modifications/keychron-k6.json ] || ln -s $(PWD)/karabiner/keychron-k6.json ~/.config/karabiner/assets/complex_modifications/keychron-k6.json
message "success" "links setup"
}
install_extras() {
message "info" "installing extra tools"
# install nerd fonts for nice icons
brew tap homebrew/cask-fonts
brew install font-hack-nerd-font
# install espanso
brew tap espanso/espanso
brew install espanso
[ -f ~/Library/Application\ Support/espanso/match/base.yml ] || ln -s $(PWD)/espanso_base.yml ~/Library/Application\ Support/espanso/match/base.yml
brew install gh
brew cleanup
# install gh extensions
gh extension install dlvhdr/gh-dash
message "success" "extra tools installed"
}
clean() {
message "info" "cleaning up (removing links)"
rm -rf ~/.config/tmux
rm -f ~/.gitconfig
rm -rf ~/.config/git
rm -f ~/.zshrc
rm -rf ~/.config/zsh
rm -rf ~/.config/kitty
rm -rf ~/.config/nvim
rm -f ~/.config/starship.toml
rm -f ~/Library/Application\ Support/espanso/match/base.yml
message "success" "cleaned up"
}
karabiner() {
message "info" "setup custom capslock in karabiner"
[ -f ~/.config/karabiner/assets/complex_modifications/custom_capslock.json ] || ln -s $(PWD)/karabiner/custom_capslock.json ~/.config/karabiner/assets/complex_modifications/custom_capslock.json
}
case $1 in
setup)
message "info" "setting up everything"
homebrew || message "error" "failed to install homebrew"
core || message "error" "failed to install core tools"
install_extras || message "error" "failed to install extra tools"
setup_links || message "error" "failed to setup links"
;;
homebrew)
homebrew || message "error" "failed to install homebrew"
;;
core)
core || message "error" "failed to install core tools"
;;
links)
setup_links || message "error" "failed to setup links"
;;
extras)
install_extras || message "error" "failed to install extra tools"
;;
clean)
clean || message "error" "failed to clean up"
;;
karabiner)
karabiner || message "error" "failed to setup karabiner"
;;
esac