From a8091c11751f02156ffc6b7549310162e932e520 Mon Sep 17 00:00:00 2001 From: Diana <65094216+dianaw353@users.noreply.github.com> Date: Sun, 10 Nov 2024 13:20:25 -0700 Subject: [PATCH] arch setup use for loop instead of if statments --- dotfiles.sh | 40 ++++++---------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/dotfiles.sh b/dotfiles.sh index 6ed2f9b9..524d05c1 100644 --- a/dotfiles.sh +++ b/dotfiles.sh @@ -136,40 +136,12 @@ function backup_dotfiles() { # Arch setup function function arch_setup { - if ! [ -x "$(command -v ansible)" ]; then - _task "Installing Ansible" - _cmd "sudo pacman -Sy --noconfirm" - _cmd "sudo pacman -S --noconfirm ansible" - _cmd "sudo pacman -S --noconfirm python-argcomplete" - fi - if ! pacman -Q python3 >/dev/null 2>&1; then - _task "Installing Python3" - _cmd "sudo pacman -S --noconfirm python" - fi - if ! pacman -Q python-pip >/dev/null 2>&1; then - _task "Installing Python3 Pip" - _cmd "sudo pacman -S --noconfirm python-pip" - fi - if ! pip3 list | grep watchdog >/dev/null 2>&1; then - _task "Installing Python3 Watchdog" - _cmd "sudo pacman -S --noconfirm python-watchdog" - fi - if ! pacman -Q openssh >/dev/null 2>&1; then - _task "Installing OpenSSH" - _cmd "sudo pacman -S --noconfirm openssh" - fi - if ! pacman -Q rsync >/dev/null 2>&1; then - _task "Installing Rsync" - _cmd "sudo pacman -S --noconfirm rsync" - fi - if ! pacman -Q git >/dev/null 2>&1; then - _task "Installing Git" - _cmd "sudo pacman -S --noconfirm git" - fi - if ! pacman -Q noto-fonts-emoji >/dev/null 2>&1; then - _task "Installing Noto emoji fonts" - _cmd "sudo pacman -S --noconfirm noto-fonts-emoji" - fi + for pkg in ansible python python-pip python-watchdog openssh rsync git noto-fonts-emoji; do + if ! pacman -Q $pkg >/dev/null 2>&1; then + _task "Installing $pkg" + _cmd "sudo pacman -S --noconfirm $pkg" + fi + done } # Function to update Ansible Galaxy