From 032e26b56646bf8c6e8a114db4641493130509f3 Mon Sep 17 00:00:00 2001 From: "mateusz.kozakowski" Date: Mon, 13 Jan 2025 21:37:37 +0100 Subject: [PATCH] feat: add shell integration setup for fastfetch --- .../applications-setup/fastfetch-setup.sh | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/core/tabs/applications-setup/fastfetch-setup.sh b/core/tabs/applications-setup/fastfetch-setup.sh index 5374805e..a4621e3a 100644 --- a/core/tabs/applications-setup/fastfetch-setup.sh +++ b/core/tabs/applications-setup/fastfetch-setup.sh @@ -35,7 +35,52 @@ setupFastfetchConfig() { curl -sSLo "${HOME}/.config/fastfetch/config.jsonc" https://raw.githubusercontent.com/ChrisTitusTech/mybash/main/config.jsonc } +setupFastfetchShell() { + printf "%b\n" "${YELLOW}Configuring shell integration...${RC}" + + # Get current shell and RC file path + current_shell=$(basename "$SHELL") + rc_file="" + + case "$current_shell" in + "bash") + rc_file="$HOME/.bashrc" + ;; + "zsh") + rc_file="$HOME/.zshrc" + ;; + *) + printf "%b\n" "${RED}Unsupported shell: $current_shell${RC}" + return 1 + ;; + esac + + # Check if RC file exists + if [ ! -f "$rc_file" ]; then + printf "%b\n" "${RED}Shell config file not found: $rc_file${RC}" + return 1 + fi + + # Check if fastfetch is already in RC file + if grep -q "fastfetch" "$rc_file"; then + printf "%b\n" "${YELLOW}Fastfetch is already configured in $rc_file${RC}" + return 0 + fi + + # Ask for confirmation + printf "%b" "${GREEN}Would you like to add fastfetch to $rc_file? [y/N] ${RC}" + read -r response + + if [ "$response" = "y" ] || [ "$response" = "Y" ]; then + printf "\n# Run fastfetch on terminal start\nfastfetch\n" >> "$rc_file" + printf "%b\n" "${GREEN}Added fastfetch to $rc_file${RC}" + else + printf "%b\n" "${YELLOW}Skipped adding fastfetch to shell config${RC}" + fi +} + checkEnv checkEscalationTool installFastfetch -setupFastfetchConfig \ No newline at end of file +setupFastfetchConfig +setupFastfetchShell \ No newline at end of file