From eaa08e9eaa562426705696fad26792cd7d8bcef2 Mon Sep 17 00:00:00 2001 From: Parham Alvani Date: Wed, 4 Oct 2023 04:19:03 +0000 Subject: [PATCH] feat: update insomnia installation script --- scripts/insomnia.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/scripts/insomnia.sh b/scripts/insomnia.sh index c0ab4c25d..052cdb424 100644 --- a/scripts/insomnia.sh +++ b/scripts/insomnia.sh @@ -27,3 +27,38 @@ main_brew() { main() { return 0 } + +main_parham() { + mkdir -p "$HOME/.config/Insomnia/" || true + + if [ -d "$HOME/.config/Insomnia/version_control" ]; then + cd "$HOME/.config/Insomnia/version_control" || return + + url=$(git remote get-url origin 2>/dev/null) + if [[ "$url" =~ .*github.com[:/]1995parham-me/insomnia ]]; then + msg 'valid repository, so fetching it' + git pull origin main + + return 0 + else + msg "invalid repository $url" + + if yes_or_no "insomnia" "do you want to remove current insomnia configuration?"; then + msg 'removing current configuration to replace it with new configuration' + rm -Rf "$HOME/.config/Insomnia/version_control" + else + return 1 + fi + fi + fi + + if [ -e "$HOME/.config/Insomnia/version_control" ] || [ -L "$HOME/.config/Insomnia/version_control" ]; then + if yes_or_no "insomnia" "do you want to remove current insomnia configuration?"; then + msg 'removing current configuration to replace it with new configuration' + rm -Rf "$HOME/.config/Insomnia/version_control" + else + return 1 + fi + fi + git clone git@github.com:1995parham-me/insomnia "$HOME/.config/Insomnia/version_control" +}