mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2025-01-31 06:35:41 +00:00
Update fastfetch-setup.sh - improved logic
This commit is contained in:
parent
032e26b566
commit
9cb5d3a7c1
|
@ -6,20 +6,20 @@ 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}"
|
||||||
|
@ -43,40 +43,40 @@ setupFastfetchShell() {
|
||||||
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"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
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
|
|
||||||
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
|
else
|
||||||
printf "%b\n" "${YELLOW}Skipped adding fastfetch to shell config${RC}"
|
# 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
|
||||||
|
else
|
||||||
|
# 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
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checkEnv
|
checkEnv
|
||||||
|
|
Loading…
Reference in New Issue
Block a user