Update fastfetch-setup.sh - fmt

This commit is contained in:
mateuszkozako 2025-01-29 21:12:54 +01:00 committed by GitHub
parent d52af3fafb
commit 77c4441e11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,79 +3,79 @@
. ../common-script.sh . ../common-script.sh
installFastfetch() { installFastfetch() {
if ! command_exists fastfetch; then if ! command_exists fastfetch; then
printf "%b\n" "${YELLOW}Installing Fastfetch...${RC}" printf "%b\n" "${YELLOW}Installing Fastfetch...${RC}"
case "$PACKAGER" in case "$PACKAGER" in
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
;; ;;
apk) apk)
"$ESCALATION_TOOL" "$PACKAGER" add fastfetch "$ESCALATION_TOOL" "$PACKAGER" add fastfetch
;; ;;
*) *)
"$ESCALATION_TOOL" "$PACKAGER" install -y fastfetch "$ESCALATION_TOOL" "$PACKAGER" install -y fastfetch
;; ;;
esac esac
else else
printf "%b\n" "${GREEN}Fastfetch is already installed.${RC}" printf "%b\n" "${GREEN}Fastfetch is already installed.${RC}"
fi fi
} }
setupFastfetchConfig() { setupFastfetchConfig() {
printf "%b\n" "${YELLOW}Copying Fastfetch config files...${RC}" printf "%b\n" "${YELLOW}Copying Fastfetch config files...${RC}"
if [ -d "${HOME}/.config/fastfetch" ] && [ ! -d "${HOME}/.config/fastfetch-bak" ]; then if [ -d "${HOME}/.config/fastfetch" ] && [ ! -d "${HOME}/.config/fastfetch-bak" ]; then
cp -r "${HOME}/.config/fastfetch" "${HOME}/.config/fastfetch-bak" cp -r "${HOME}/.config/fastfetch" "${HOME}/.config/fastfetch-bak"
fi fi
mkdir -p "${HOME}/.config/fastfetch/" mkdir -p "${HOME}/.config/fastfetch/"
curl -sSLo "${HOME}/.config/fastfetch/config.jsonc" https://raw.githubusercontent.com/ChrisTitusTech/mybash/main/config.jsonc curl -sSLo "${HOME}/.config/fastfetch/config.jsonc" https://raw.githubusercontent.com/ChrisTitusTech/mybash/main/config.jsonc
} }
setupFastfetchShell() { setupFastfetchShell() {
printf "%b\n" "${YELLOW}Configuring shell integration...${RC}" printf "%b\n" "${YELLOW}Configuring shell integration...${RC}"
current_shell=$(basename "$SHELL") current_shell=$(basename "$SHELL")
rc_file="" rc_file=""
case "$current_shell" in case "$current_shell" in
"bash") "bash")
rc_file="$HOME/.bashrc" rc_file="$HOME/.bashrc"
;; ;;
"zsh") "zsh")
rc_file="$HOME/.zshrc" rc_file="$HOME/.zshrc"
;; ;;
"fish") "fish")
rc_file="$HOME/.config/fish/config.fish" rc_file="$HOME/.config/fish/config.fish"
;; ;;
"nu") "nu")
rc_file="$HOME/.config/nushell/config.nu" rc_file="$HOME/.config/nushell/config.nu"
;; ;;
*) *)
printf "%b\n" "${RED}$current_shell is not supported. Update your shell configuration manually.${RC}" printf "%b\n" "${RED}$current_shell is not supported. Update your shell configuration manually.${RC}"
;; ;;
esac esac
if [ ! -f "$rc_file" ]; then if [ ! -f "$rc_file" ]; then
printf "%b\n" "${RED}Shell config file $rc_file not found${RC}" printf "%b\n" "${RED}Shell config file $rc_file not found${RC}"
else else
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
else else
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 shell initialization\nfastfetch\n" >>"$rc_file" printf "\n# Run fastfetch on shell initialization\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
fi fi
} }