-
Notifications
You must be signed in to change notification settings - Fork 13
/
defaults.sh
272 lines (232 loc) · 6.69 KB
/
defaults.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
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
#!/bin/bash /bin/zsh
##########################################################
# conventions
##########################################################
# uppercase for global variables
# lowercase for local variables
##########################################################
# basic settings
##########################################################
# default editor, can be changed by function `ched()`
export EDITOR='code'
# terminal editor
export EDITOR_T='vi'
##########################################################
# select ox-plugins
##########################################################
# package managers
# - oxppc: conda
# - oxppcn: conan (c++)
# - oxppnj: npm + yarn
# - oxpptl: tlmgr (texlive)
# languages
# - oxpljl: julia
# - oxplrb: ruby (include gem)
# - oxplrs: rust (include cargo)
# services
# - oxpsc: container (docker & podman)
# - oxpsp: pueue
# app cli
# - oxpcg: git
# - oxpcbw: bitwarden
# - oxpces: espanso
# - oxpcjr: jupyter (notebook, lab, book)
# - oxpcvs: vscode
# system utils
# - oxpufm: format conversion
# terminal utils
# - oxptwr: weather
# - oxptzj: zellij
# extra utils
# - oxpxns: notes
OX_PLUGINS=(
oxpcg
oxpufm
)
##########################################################
# select software configuration objects
##########################################################
# backup file path
export OX_BACKUP=${HOME}/Documents/backup
# shellscripts
# the key should meet the following requirements
# 1. starts with `bk`
# 2. keeps consistent with the key in `OX_ELEMENT` (if it exists)
# the oxidizer backup path
OX_OXIDE[bkox]=${OX_BACKUP}/shell/custom.sh
##########################################################
# vim & neovim
##########################################################
OX_OXIDE[bkvi]=${OX_BACKUP}/shell/.vimrc
##########################################################
# terminal
##########################################################
case $(uname -a) in
*Darwin* | *Ubuntu* | *Debian*)
OX_ELEMENT[wz]=${HOME}/.config/wezterm/wezterm.lua
;;
*MINGW*)
OX_ELEMENT[wz]=${HOME}/.wezterm.lua
if [[ -z "${OX_ELEMENT[wz]}" ]]; then
touch "${OX_ELEMENT[wz]}"
fi
;;
esac
OX_OXIDE[bkwz]=${OX_BACKUP}/terminal/wezterm.lua
##########################################################
# proxy and mirror settings
##########################################################
# to use proxy and mirrors for faster download, don't forget to add `oxpnw` in `OX_PLUGINS`
# c: clash, m: clash-meta, v: v2ray
declare -A OX_PROXY=(
[c]=7890
[m]=7897
[v]=1080
)
# use `mrb [key]` for brew mirror, use `mrbq` for quit brew mirror
# declare -A MIRRORS=(
# [bts]="mirrors.tuna.tsinghua.edu.cn/git/homebrew"
# [bzk]="mirrors.ustc.edu.cn/git/homebrew"
# )
##########################################################
# common aliases
##########################################################
# shortcuts
alias ..="cd .."
alias ...="cd ../.."
alias ~="cd ~"
alias zz="cd -"
alias cat="bat"
alias ls="lsd"
alias ll="ls -l"
alias la="ls -a"
alias lla="ls -la"
alias du="dust"
alias e="echo"
alias rr="rm -rf"
alias c="clear"
# shellcheck disable=SC2139
alias own="sudo chown -R $(whoami)"
# tools
alias tldr="tlrc"
alias man="tlrc"
alias hf="hyperfine"
# oxidizer
# export config
alias epf="oxf"
# import config
alias ipf="rdf"
# initialize config
alias iif="clzf"
##########################################################
# shell
##########################################################
# clean history
ccc() {
case ${SHELL} in
*zsh)
local HISTSIZE=0 && history -p && reset && echo >"${OX_ELEMENT[zshst]}"
;;
*bash)
local HISTSIZE=0 && history -c && reset && echo >"${OX_ELEMENT[bshst]}"
;;
esac
}
# configuration
case ${SHELL} in
*zsh)
autoload -Uz edit-command-line
zle -N edit-command-line
# turn case sensitivity off
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# other options
zstyle ':completion:*' menu select
zstyle ":completion:*" file-sort change
zstyle ":completion:*" use-cache yes
# pasting with tabs doesn't perform completion
zstyle ':completion:' insert-tab pending
;;
*bash)
# turn case sensitivity off
if [ ! -e "${HOME}"/.inputrc ]; then
# shellcheck disable=SC2016
echo '$include /etc/inputrc' >"${HOME}"/.inputrc
fi
echo 'set completion-ignore-case On' >>"${HOME}"/.inputrc
;;
esac
# test profile loading time
tt() {
case ${SHELL} in
*zsh)
hyperfine --warmup 3 --shell zsh "source ${OX_ELEMENT[zs]}"
;;
*bash)
hyperfine --warmup 3 --shell bash "source ${OX_ELEMENT[bs]}"
;;
esac
}
##########################################################
# startup commands
##########################################################
# installer downloaded path: works for function `brp()`
# use `which brp` to check `brp()` in details
export OX_DOWNLOAD=${HOME}/Desktop
export OX_STARTUP=1
startup() {
# start directory
cd "${HOME}" || exit
}
##########################################################
# brew settings
##########################################################
case $(uname -a) in
*Darwin* | *Ubuntu* | *Debian*)
export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_ENV_HINTS=1
export HOMEBREW_CLEANUP_MAX_AGE_DAYS="3"
# predefined brew services
# set the length of key <= 3
declare -A HOMEBREW_SERVICE=(
[pu]="pueue"
[pg]="postgresql@15"
[pd]="podman"
)
;;
esac
##########################################################
# pueue settings
##########################################################
# pueue demo
upp() {
pueue group add up_all
pueue parallel 3 -g up_all
pueue add -g up_all 'brew update && brew upgrade'
pueue add -g up_all 'conda update --all --yes'
# or use predefined items in pueue_aliases
# pueue add -g up_all 'cup'
}
##########################################################
# conda settings
##########################################################
# # predefined conda environments
# # set the length of key <= 3
# declare -A OX_CONDA_ENV=(
# [b]="base"
# [k]="kaggle"
# )
# # conda env stats with bkce, and should be consistent with OX_CONDA_ENV
# OX_OXIDE[bkceb]=${OX_BACKUP}/conda/conda-base.txt
##########################################################
# others settings
##########################################################
# git
OX_OXIDE[bkg]=${OX_BACKUP}/.gitconfig
OX_OXIDE[bkgi]=${OX_BACKUP}/git/.gitignore
# OX_OXIDE[bkesb]=${OX_BACKUP}/espanso/match/base.yml
# vscode
# OX_OXIDE[bkvs]=${OX_BACKUP}/vscode/settings.jsonc
##########################################################
# notes apps
##########################################################
# OX_OXIDIAN=""