-
Notifications
You must be signed in to change notification settings - Fork 14
/
install.sh
140 lines (117 loc) Β· 4.21 KB
/
install.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
#!/bin/bash /bin/zsh
export OXIDIZER=${OXIDIZER:-"${HOME}/oxidizer"}
printf "π¦ Installing Oxidizer\n"
###################################################
# Install Homebrew
###################################################
if ! command -v brew >/dev/null 2>&1; then
printf "π¦ Homebrew not installed. Installing.\n"
if [[ $(uname -s) = "Linux" ]] && [[ $(uname -m) = "aarch64" ]]; then
printf "β οΈ Oxidizer doesn't support limited Linux-son-ARM yet."
sleep 5
exit
elif [[ ${BREW_CN} ]]; then
/bin/bash -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
else
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
fi
if [[ $(uname -s) = "Darwin" ]]; then
printf "π¦ Activating Homebrew on MacOS...\n"
if [[ $(uname -m) = "arm64" ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
echo 'export PATH="/opt/homebrew/bin:$PATH"' >>~/.zshrc
else
eval "$(/usr/local/Homebrew/bin/brew shellenv)"
fi
else
printf "π¦ Activating Homebrew on Linux...\n"
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >>.profile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
brew tap "homebrew/services"
brew tap "homebrew/bundle"
###################################################
# Install Packages
###################################################
printf "π¦ Installing essential Oxidizer toolchains...\n"
while read -r pkg; do
case $pkg in
ripgrep)
cmd='rg'
;;
tlrc)
cmd='tldr'
;;
zoxide)
cmd='z'
;;
*)
cmd=$pkg
;;
esac
if ! command -v "$cmd" >/dev/null 2>&1; then
printf "%s not found, installing...\n" "$pkg"
brew install "$pkg"
fi
done <"${OXIDIZER}"/defaults/install.txt
###################################################
# Install Zap
###################################################
if [[ $(uname -s) = "Linux" ]]; then
printf "π¦ Adding Tap linuxbrew/fonts...\n"
brew tap "linuxbrew/fonts"
fi
###################################################
# Update Shell Settings
###################################################
printf "βοΈ Configuring Shell...\n"
case ${SHELL} in
*zsh)
brew install zsh-completions zsh-autosuggestions zsh-syntax-highlighting
export OX_SHELL=${HOME}/.zshrc
;;
*bash)
if [[ $(bash --version | head -n1 | cut -d' ' -f4 | cut -d'.' -f1) -lt 5 ]]; then
printf "π¦ Installing latest Bash...\n"
brew install bash bash-completion
fi
if [[ -f "${HOME}/.bashrc" ]]; then
export OX_SHELL=${HOME}/.bashrc
elif [[ -f "${HOME}/.bash_profile" ]]; then
export OX_SHELL=${HOME}/.profile
fi
echo 'export BASH_SILENCE_DEPRECATION_WARNING=1' >>"${OX_SHELL}"
;;
esac
###################################################
# Inject Oxidizer
###################################################
printf 'βοΈ Adding Oxidizer into %s...\n' "${OX_SHELL}"
echo "# Oxidizer" >>"${OX_SHELL}"
if [[ -z ${OXIDIZER} ]]; then
OXIDIZER="${HOME}/oxidizer"
append_str='export OXIDIZER='${OXIDIZER}' && source '${OXIDIZER}'/oxidizer.sh'
else
append_str='source '${OXIDIZER}'/oxidizer.sh'
fi
echo "${append_str}" >>"${OX_SHELL}"
printf "βοΈ Adding Custom settings..."
if [[ ! -f "${OXIDIZER}/"custom.sh ]]; then
cp "${OXIDIZER}"/defaults.sh "${OXIDIZER}/"custom.sh
fi
# load zoxide
sd '.* OX_STARTUP=.*' 'export OX_STARTUP=1' "${OXIDIZER}"/custom.sh
# set path of oxidizer
# echo "source OXIDIZER=${OXIDIZER}/oxidizer.sh" | xargs -I '{}' sd '' 'source OXIDIZER=.*' '{}' ${OX_SHELL}
# echo $(cat ${OX_SHELL} | rg -o 'source .+')
###################################################
# Load Plugins
###################################################
git clone --depth=1 https://github.com/ivaquero/oxplugins.git "${OXIDIZER}"/plugins
###################################################
# Editor
###################################################
printf "π Oxidizer installation complete!\n"
printf "π‘ Don't forget to restart your terminal and hit 'edf ox' to tweak your preferences.\n"
printf "π Finally, run 'upox' function to activate the plugins. Enjoy!\n"