From 82e164c4e213adb3f71192ec36a2687df5f43b8d Mon Sep 17 00:00:00 2001 From: data-tangles Date: Tue, 7 May 2024 18:20:55 +0200 Subject: [PATCH 1/3] feat: add various conditional checks to script --- linux/setup.sh | 39 +++++++++++++++++++++++++++++------- linux/starship/starship.toml | 2 +- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/linux/setup.sh b/linux/setup.sh index 5731118..c0da979 100755 --- a/linux/setup.sh +++ b/linux/setup.sh @@ -1,4 +1,10 @@ #!/usr/bin/env bash +set -eo pipefail + +# Global Variables +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +readonly SCRIPT_DIR +NERD_FONTS_VERSION="3.2.1" # Initialize status variables for each installation option gogh_status="Install Gogh [ ]" @@ -29,7 +35,7 @@ install_nerd_fonts() { fi for font in "${fonts[@]}"; do zip_file="${font}.zip" - download_url="https://github.com/ryanoasis/nerd-fonts/releases/download/latest/${zip_file}" + download_url="https://github.com/ryanoasis/nerd-fonts/releases/download/v${NERD_FONTS_VERSION}/${zip_file}" echo "Downloading $download_url" wget "$download_url" unzip "$zip_file" -d "$fonts_dir" @@ -50,7 +56,7 @@ install_starship() { curl -sS https://starship.rs/install.sh | sh echo 'eval "$(starship init bash)"' >> ~/.bashrc echo "Replace starship.toml file..." - cp -f ./linux/starship/starship.toml ~/.config/ + cp -f "$SCRIPT_DIR/starship/starship.toml" ~/.config/ if [[ $? -eq 0 ]]; then starship_status="Install Starship [✔]" else @@ -61,22 +67,41 @@ install_starship() { # Function to install ble.sh install_ble_sh() { echo "Installing ble.sh prerequisites and running make..." - sudo apt install gawk + sudo apt install make gawk git clone --recursive https://github.com/akinomyoga/ble.sh.git cd ble.sh || exit - make echo "Installing ble.sh..." make install - echo "Adding ble.sh config to .bashrc..." - sed -i "1i [[ \$- == *i* ]] && source ~/.local/share/blesh/ble.sh --noattach" ~/.bashrc - echo "[[ ${BLE_VERSION-} ]] && ble-attach" >> ~/.bashrc + if grep -Fxq "[[ $- == *i* ]] && source ~/.local/share/blesh/ble.sh --noattach" ~/.bashrc; then + echo "Entry is present, skipping ~/.bashrc modification..." + else + echo "Adding ble.sh source config to .bashrc..." + sed -i "1i [[ \$- == *i* ]] && source ~/.local/share/blesh/ble.sh --noattach" ~/.bashrc + echo "[[ \${BLE_VERSION-} ]] && ble-attach" >> ~/.bashrc + fi + if grep -Fxq "[[ ${BLE_VERSION-} ]] && ble-attach" ~/.bashrc; then + echo "Entry is present, skipping ~/.bashrc modification..." + else + echo "Adding ble.sh attach config to .bashrc..." + echo "[[ \${BLE_VERSION-} ]] && ble-attach" >> ~/.bashrc + fi if [[ $? -eq 0 ]]; then ble_sh_status="Install ble.sh [✔]" + rm -rf ble.sh else ble_sh_status="Install ble.sh [✘]" + rm -rf ble.sh fi } +#Function to install all +install_all() { + install_gogh + install_nerd_fonts + install_starship + install_ble_sh +} + # Main function to display the menu main_menu() { echo " diff --git a/linux/starship/starship.toml b/linux/starship/starship.toml index 2bf7088..1029a40 100644 --- a/linux/starship/starship.toml +++ b/linux/starship/starship.toml @@ -141,4 +141,4 @@ format = '[ $symbol ($version) ]($style)' disabled = false time_format = "%R" # Hour:Minute Format style = "bg:#33658A" -format = '[ $time ]($style)' +format = '[ $time ]($style)' \ No newline at end of file From 60691c536735a9e990bf1e44728718f9185d6174 Mon Sep 17 00:00:00 2001 From: Cuan Leo Date: Wed, 8 May 2024 08:40:55 +0200 Subject: [PATCH 2/3] fix: add startship bashrc modification check --- .github/workflows/main.yml | 1 - linux/setup.sh | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 60bf6d3..8601d0f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,6 @@ on: push: branches: - "main" - pull_request: permissions: contents: write diff --git a/linux/setup.sh b/linux/setup.sh index c0da979..fc32da0 100755 --- a/linux/setup.sh +++ b/linux/setup.sh @@ -54,7 +54,12 @@ install_nerd_fonts() { install_starship() { echo "Installing Starship..." curl -sS https://starship.rs/install.sh | sh - echo 'eval "$(starship init bash)"' >> ~/.bashrc + if grep -Fxq "eval \"$(starship init bash)\"" ~/.bashrc; then + echo "Entry is present, skipping ~/.bashrc modification..." + else + echo "Adding starship config to .bashrc..." + echo 'eval "$(starship init bash)"' >> ~/.bashrc + fi echo "Replace starship.toml file..." cp -f "$SCRIPT_DIR/starship/starship.toml" ~/.config/ if [[ $? -eq 0 ]]; then From 795a531d28ce1eae5140c697c0b78e8f97c263b4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 8 May 2024 06:41:49 +0000 Subject: [PATCH 3/3] chore(release): v0.1.1 [skip ci] --- CHANGELOG.md | 7 +------ package.yaml | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ba6e11..973c866 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,4 @@ -# 0.1.0 (2024-05-05) - - -### Bug Fixes - -* Correct GitHub actions workflow ([7a0bd37](https://github.com/data-tangles/shell-config/commit/7a0bd37a5bbab3e63aabecde25fd6d5736e8878c)) +## 0.1.1 (2024-05-08) diff --git a/package.yaml b/package.yaml index 5593cd8..2dc19f0 100644 --- a/package.yaml +++ b/package.yaml @@ -1 +1 @@ -version: 0.1.0 +version: 0.1.1