Update fastfetch-setup.sh - improved logic

This commit is contained in:
mateuszkozako 2025-01-20 11:09:39 +01:00 committed by GitHub
parent 032e26b566
commit 9cb5d3a7c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,7 +9,7 @@ installFastfetch() {
pacman) pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm fastfetch "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm fastfetch
;; ;;
apt-get|nala) apt-get | nala)
curl -sSLo /tmp/fastfetch.deb https://github.com/fastfetch-cli/fastfetch/releases/latest/download/fastfetch-linux-amd64.deb curl -sSLo /tmp/fastfetch.deb https://github.com/fastfetch-cli/fastfetch/releases/latest/download/fastfetch-linux-amd64.deb
"$ESCALATION_TOOL" "$PACKAGER" install -y /tmp/fastfetch.deb "$ESCALATION_TOOL" "$PACKAGER" install -y /tmp/fastfetch.deb
rm /tmp/fastfetch.deb rm /tmp/fastfetch.deb
@ -50,33 +50,33 @@ setupFastfetchShell() {
rc_file="$HOME/.zshrc" rc_file="$HOME/.zshrc"
;; ;;
*) *)
printf "%b\n" "${RED}Unsupported shell: $current_shell${RC}" printf "%b\n" "${RED}You sre using shell other than zsh and bash, your shell is: $current_shell${RC}, therefore you have to manually update your rc file."
return 1 other_shell=True
;; ;;
esac esac
# Check if RC file exists # Check if RC file exists
if [ ! -f "$rc_file" ]; then if [ ! -f "$rc_file" ] || [ "$other_shell" != "True" ]; then
printf "%b\n" "${RED}Shell config file not found: $rc_file${RC}" printf "%b\n" "${RED}Shell config file $rc_file${RC} not found"
return 1 else
fi
# Check if fastfetch is already in RC file # Check if fastfetch is already in RC file
if grep -q "fastfetch" "$rc_file"; then if grep -q "fastfetch" "$rc_file"; then
printf "%b\n" "${YELLOW}Fastfetch is already configured in $rc_file${RC}" printf "%b\n" "${YELLOW}Fastfetch is already configured in $rc_file${RC}"
return 0 return 0
fi else
# Ask for confirmation # Ask for confirmation
printf "%b" "${GREEN}Would you like to add fastfetch to $rc_file? [y/N] ${RC}" printf "%b" "${GREEN}Would you like to add fastfetch to $rc_file? [y/N] ${RC}"
read -r response read -r response
if [ "$response" = "y" ] || [ "$response" = "Y" ]; then if [ "$response" = "y" ] || [ "$response" = "Y" ]; then
printf "\n# Run fastfetch on terminal start\nfastfetch\n" >> "$rc_file" printf "\n# Run fastfetch on terminal start\nfastfetch\n" >>"$rc_file"
printf "%b\n" "${GREEN}Added fastfetch to $rc_file${RC}" printf "%b\n" "${GREEN}Added fastfetch to $rc_file${RC}"
else else
printf "%b\n" "${YELLOW}Skipped adding fastfetch to shell config${RC}" printf "%b\n" "${YELLOW}Skipped adding fastfetch to shell config${RC}"
fi fi
fi
fi
} }
checkEnv checkEnv