-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.sh
More file actions
executable file
·170 lines (145 loc) · 3.93 KB
/
common.sh
File metadata and controls
executable file
·170 lines (145 loc) · 3.93 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
#!/bin/bash
export _NORM="\\033[0m"
export _BLK="\\033[0;30m"
export _BBLK="\\033[1;30m"
export _RED="\\033[0;31m"
export _BRED="\\033[1;31m"
export _GRN="\\033[0;32m"
export _BGRN="\\033[1;32m"
export _YEL="\\033[0;33m"
export _BYEL="\\033[1;33m"
export _BLU="\\033[0;34m"
export _BBLU="\\033[1;34m"
export _MAG="\\033[0;35m"
export _BMAG="\\033[1;35m"
export _CYN="\\033[0;36m"
export _BCYN="\\033[1;36m"
export _WHT="\\033[0;37m"
export _BWHT="\\033[1;37m"
function install_nerd_fonts() {
local font_dir="${HOME}/.local/share/fonts/JetBrainsMonoNerdFont"
if [[ -d "${font_dir}" ]]; then
debug "JetBrainsMono Nerd Font already installed" "${_GRN}"
return 0
fi
debug "Installing JetBrainsMono Nerd Font..." "${_GRN}"
mkdir -p "${font_dir}"
local zip_file="/tmp/JetBrainsMono.zip"
curl -fLo "${zip_file}" "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/JetBrainsMono.zip"
unzip -o "${zip_file}" -d "${font_dir}"
rm "${zip_file}"
if command -v fc-cache >/dev/null 2>&1; then
fc-cache -fv
fi
}
function debug() {
msg=$1
color=${2:-${_NORM}}
echo -e "${color}${msg}${_NORM}"
}
function is_bazzite_based() {
if [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
bazzite)
return 0
;;
*)
return 1
;;
esac
fi
}
function is_debian_based() {
if [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
ubuntu | debian | raspbian)
return 0
;;
*)
return 1
;;
esac
fi
# Fallback for older systems without /etc/os-release
if [ -f /etc/debian_version ]; then
return 0
else
return 1
fi
}
function is_fedora_based() {
if [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
fedora | centos)
return 0
;;
*)
return 1
;;
esac
fi
# Fallback for older systems without /etc/os-release
if [ -f /etc/fedora-release ]; then
return 0
else
return 1
fi
}
function setup_common() {
debug "Installing base16-shell" "${_GRN}"
if [[ ! -e ~/.config/base16-shell ]]; then
git clone https://github.com/chriskempson/base16-shell.git ~/.config/base16-shell
fi
debug "Setting up vim base16 colorscheme" "${_GRN}"
echo 'colorscheme base16-material' >~/.vimrc_background
if [[ "${OSTYPE}" == "linux-gnu" ]]; then
install_nerd_fonts
fi
debug "Installing mise" "${_GRN}"
if [[ ! "$("${HOME}"/.local/bin/mise --version)" ]]; then
local mise_exec="mise_install.sh"
curl -o "${mise_exec}" https://mise.run
chmod +x "${mise_exec}"
./"${mise_exec}"
rm "${mise_exec}"
eval "$("${HOME}"/.local/bin/mise activate zsh)"
fi
if command -v zsh >/dev/null 2>&1 && [[ "$(basename "$SHELL")" != "zsh" ]]; then
debug "Changing default shell to zsh" "${_GRN}"
chsh -s "$(which zsh)"
fi
debug "Pulling Thoughtbot Dotfiles" "${_GRN}"
MY_DOTFILES=$HOME/projects/dotfiles
TB_DOTFILES=$HOME/projects/dotfiles-thoughtbot
if [ ! -e "$TB_DOTFILES" ]; then
git clone https://github.com/thoughtbot/dotfiles.git "$TB_DOTFILES"
fi
pushd "$TB_DOTFILES" || exit
git pull
popd || exit
pushd "$MY_DOTFILES" || exit
git pull
popd || exit
debug "Installing Dotfiles" "${_GRN}"
rcup -f -d "$TB_DOTFILES" -x gitconfig -x '*.md' -x LICENSE -x hushlogin -x rcrc
rcup -f -d "$MY_DOTFILES" -t config -x README.md -x '*.sh'
if [[ ! -e ~/.config/nvim ]]; then
debug "Linking for neovim" "${_GRN}"
ln -s ~/.vim ~/.config/nvim
fi
if [[ ! -e ~/.config/nvim/init.vim ]]; then
debug "Link something related to neovim" "${_GRN}"
ln -s ~/.vimrc ~/.config/nvim/init.vim
fi
if [ ! -e ~/.zsh/zsh-autosuggestions ]; then
debug "Clone zsh auto suggestion" "${_GRN}"
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
fi
if [ ! -e ~/.zsh/configs/keybindings.zsh ]; then
debug "For some reason I unlink this file" "${_GRN}"
unlink ~/.zsh/configs/keybindings.zsh
fi
}