Skip to content

Commit 82e164c

Browse files
committed
feat: add various conditional checks to script
1 parent 031a553 commit 82e164c

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

linux/setup.sh

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#!/usr/bin/env bash
2+
set -eo pipefail
3+
4+
# Global Variables
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
6+
readonly SCRIPT_DIR
7+
NERD_FONTS_VERSION="3.2.1"
28

39
# Initialize status variables for each installation option
410
gogh_status="Install Gogh [ ]"
@@ -29,7 +35,7 @@ install_nerd_fonts() {
2935
fi
3036
for font in "${fonts[@]}"; do
3137
zip_file="${font}.zip"
32-
download_url="https://github.com/ryanoasis/nerd-fonts/releases/download/latest/${zip_file}"
38+
download_url="https://github.com/ryanoasis/nerd-fonts/releases/download/v${NERD_FONTS_VERSION}/${zip_file}"
3339
echo "Downloading $download_url"
3440
wget "$download_url"
3541
unzip "$zip_file" -d "$fonts_dir"
@@ -50,7 +56,7 @@ install_starship() {
5056
curl -sS https://starship.rs/install.sh | sh
5157
echo 'eval "$(starship init bash)"' >> ~/.bashrc
5258
echo "Replace starship.toml file..."
53-
cp -f ./linux/starship/starship.toml ~/.config/
59+
cp -f "$SCRIPT_DIR/starship/starship.toml" ~/.config/
5460
if [[ $? -eq 0 ]]; then
5561
starship_status="Install Starship [✔]"
5662
else
@@ -61,22 +67,41 @@ install_starship() {
6167
# Function to install ble.sh
6268
install_ble_sh() {
6369
echo "Installing ble.sh prerequisites and running make..."
64-
sudo apt install gawk
70+
sudo apt install make gawk
6571
git clone --recursive https://github.com/akinomyoga/ble.sh.git
6672
cd ble.sh || exit
67-
make
6873
echo "Installing ble.sh..."
6974
make install
70-
echo "Adding ble.sh config to .bashrc..."
71-
sed -i "1i [[ \$- == *i* ]] && source ~/.local/share/blesh/ble.sh --noattach" ~/.bashrc
72-
echo "[[ ${BLE_VERSION-} ]] && ble-attach" >> ~/.bashrc
75+
if grep -Fxq "[[ $- == *i* ]] && source ~/.local/share/blesh/ble.sh --noattach" ~/.bashrc; then
76+
echo "Entry is present, skipping ~/.bashrc modification..."
77+
else
78+
echo "Adding ble.sh source config to .bashrc..."
79+
sed -i "1i [[ \$- == *i* ]] && source ~/.local/share/blesh/ble.sh --noattach" ~/.bashrc
80+
echo "[[ \${BLE_VERSION-} ]] && ble-attach" >> ~/.bashrc
81+
fi
82+
if grep -Fxq "[[ ${BLE_VERSION-} ]] && ble-attach" ~/.bashrc; then
83+
echo "Entry is present, skipping ~/.bashrc modification..."
84+
else
85+
echo "Adding ble.sh attach config to .bashrc..."
86+
echo "[[ \${BLE_VERSION-} ]] && ble-attach" >> ~/.bashrc
87+
fi
7388
if [[ $? -eq 0 ]]; then
7489
ble_sh_status="Install ble.sh [✔]"
90+
rm -rf ble.sh
7591
else
7692
ble_sh_status="Install ble.sh [✘]"
93+
rm -rf ble.sh
7794
fi
7895
}
7996

97+
#Function to install all
98+
install_all() {
99+
install_gogh
100+
install_nerd_fonts
101+
install_starship
102+
install_ble_sh
103+
}
104+
80105
# Main function to display the menu
81106
main_menu() {
82107
echo "

linux/starship/starship.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,4 @@ format = '[ $symbol ($version) ]($style)'
141141
disabled = false
142142
time_format = "%R" # Hour:Minute Format
143143
style = "bg:#33658A"
144-
format = '[ $time ]($style)'
144+
format = '[ $time ]($style)'

0 commit comments

Comments
 (0)