-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·162 lines (139 loc) · 5.26 KB
/
setup.sh
File metadata and controls
executable file
·162 lines (139 loc) · 5.26 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
#!/usr/bin/env bash
LOCAL_CONFIG_DIR="$HOME/.config/shell"
LOCAL_CONFIG="$LOCAL_CONFIG_DIR"/local.sh
mkdir -p "$LOCAL_CONFIG_DIR"
declare -a common_packages=(
curl wget git zsh tmux bat fzf unzip neovim ripgrep ncdu ranger vim zoxide
)
install_arch() {
sudo pacman -S "${common_packages[@]}" eza github-cli fd git-delta lazygit ttf-firacode-nerd wl-clipboard mise
git clone https://aur.archlinux.org/paru-bin.git /tmp/paru-bin
cd /tmp/paru-bin || exit
makepkg -si --noconfirm
paru -S topgrade-bin --noconfirm
}
install_fedora() {
sudo dnf copr enable atim/lazygit -y
sudo dnf copr enable alternateved/eza -y
sudo dnf install "${common_packages[@]}" eza gh lazygit fd-find wl-clipboard git-delta --skip-unavailable
}
install_debian() {
sudo apt install "${common_packages[@]}" exa gh fd-find xclip autorandr nala
sudo ln -sfnv /usr/bin/fdfind /usr/bin/fd
sudo ln -sfnv /usr/bin/batcat /usr/bin/bat
sudo ln -sfnv /usr/bin/exa /usr/bin/eza
echo "alias cat=batcat" >>"$LOCAL_CONFIG"
}
install_termux() {
pkg install "${common_packages[@]}" eza gh fd git-delta openssh termux-tools nala
ln -sfnv "$PWD/../config/bin" "$HOME"/bin
cp -rv "$PWD/../config/.termux" "$HOME"/
}
install_unknown() {
echo "Unknown system detected: $system_kind"
echo "Please select a system type to use for package installation:"
echo "1) Arch Linux (arch, archarm, manjaro)"
echo "2) Debian/Ubuntu (ubuntu, debian, pop, kali)"
echo "3) Fedora (fedora, fedora-asahi-remix)"
echo "4) Termux"
echo -en "\u001b[32;1m ==> \u001b[0m"
read -r selection
case $selection in
1) color="033" && install_arch ;;
2) color="163" && install_debian ;;
3) color="32" && install_fedora ;;
4) color="040" && install_termux ;;
*) echo "Invalid selection, exiting." && exit 1 ;;
esac
}
get_system_info() {
[ -e /etc/os-release ] && source /etc/os-release && echo "${ID:-Unknown}" && return
[ -e /etc/lsb-release ] && source /etc/lsb-release && echo "${DISTRIB_ID:-Unknown}" && return
[ "$(uname)" == "Darwin" ] && echo "mac" && return
[ "$(uname -o)" == "Android" ] && echo "termux" && return
}
install_packages() {
system_kind=$(get_system_info)
echo -e "\u001b[7m Installing packages for $system_kind...\u001b[0m"
color=""
case $system_kind in
arch) color="033" && install_arch ;;
archarm) color="033" && install_arch ;;
manjaro) color="040" && install_arch ;;
debian) color="163" && install_debian ;;
kali) color="254" && install_debian ;;
pop) color="045" && install_debian ;;
ubuntu) color="202" && install_debian ;;
fedora | fedora-asahi-remix) color="32" && install_fedora ;;
termux) color="040" && install_termux ;;
mac) color="254" ;;
*) install_unknown ;;
esac
echo "export POWERLEVEL9K_OS_ICON_BACKGROUND='$color'" >>"$LOCAL_CONFIG"
echo "export POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX='%F{238}╰%F{$color}%K{$color}%F{black} %f%F{$color}%k%f'" >>"$LOCAL_CONFIG"
mkdir -p "$HOME/.local/state/vim/undo"
}
declare -a config_dirs=(
"autorandr" "bat" "bundle" "cmus" "delta" "fish" "fontconfig" "gitignore.global"
"htop" "kitty" "lazygit" "libinput-gestures.conf" "mise" "ranger" "shell" "tmux"
"zsh" "sysinfo.conkyrc" "topgrade.toml" "bluetuith" "alacritty"
)
declare -a home_files=(
"zsh/.zshenv" ".bashrc" ".dircolors" ".dmenurc" ".gitconfig" ".inputrc"
".prettierrc" ".pryrc" ".pystartup" ".reek.yml" ".typos.toml"
".vimrc" ".Xresources" ".editorconfig"
)
backup_configs() {
echo -e "\u001b[33;1m Backing up existing files... \u001b[0m"
for dir in "${config_dirs[@]}"; do
mv -v "$HOME/.config/$dir" "$HOME/.config/$dir.old"
done
for file in "${home_files[@]}"; do
mv -v "$HOME/$file" "$HOME/$file.old"
done
echo -e "\u001b[36;1m Done backing up files as '.old'! . \u001b[0m"
}
setup_symlinks() {
echo -e "\u001b[7m Setting up symlinks... \u001b[0m"
for dir in "${config_dirs[@]}"; do
ln -sfnv "$PWD/config/$dir" "$HOME/.config/"
done
for file in "${home_files[@]}"; do
ln -sfnv "$PWD/config/$file" "$HOME"/
done
}
setup_dotfiles() {
echo -e "\u001b[7m Setting up dots2k... \u001b[0m"
backup_configs
setup_symlinks
install_packages
echo -e "\u001b[7m Done! \u001b[0m"
}
show_menu() {
echo -e "\u001b[32;1m Setting up your env with dots2k...\u001b[0m"
echo -e " \u001b[37;1m\u001b[4mSelect an option:\u001b[0m"
echo -e " \u001b[34;1m (0) Setup Everything \u001b[0m"
echo -e " \u001b[34;1m (1) Backup Current Configs \u001b[0m"
echo -e " \u001b[34;1m (2) Setup Symlinks \u001b[0m"
echo -e " \u001b[34;1m (3) Install Packages \u001b[0m"
echo -e " \u001b[31;1m (*) Anything else to exit \u001b[0m"
echo -en "\u001b[32;1m ==> \u001b[0m"
read -r option
case $option in
"0") setup_dotfiles ;;
"1") backup_configs ;;
"2") setup_symlinks ;;
"3") install_packages ;;
*) echo -e "\u001b[31;1m alvida and adios! \u001b[0m" && exit 0 ;;
esac
}
main() {
case "$1" in
-a | --all | a | all) setup_dotfiles ;;
-i | --install | i | install) setup_symlinks && install_packages ;;
-s | --symlinks | s | symlinks) setup_symlinks ;;
*) show_menu ;;
esac
exit 0
}
main "$@"