refactor repeated code

This commit is contained in:
guruswarupa 2024-07-24 16:40:15 +05:30
parent 9aff333778
commit bc9bee0bc9
3 changed files with 8 additions and 35 deletions

View File

@ -1,14 +1,5 @@
#!/bin/sh -e #!/bin/sh -e
RC='\033[0m'
RED='\033[31m'
YELLOW='\033[33m'
GREEN='\033[32m'
command_exists() {
which $1 >/dev/null 2>&1
}
checkEnv() { checkEnv() {
checkCommandRequirements 'curl groups sudo' checkCommandRequirements 'curl groups sudo'
checkPackageManager 'apt-get dnf pacman zypper nix-env' checkPackageManager 'apt-get dnf pacman zypper nix-env'

View File

@ -1,14 +1,5 @@
#!/bin/sh -e #!/bin/sh -e
RC='\033[0m'
RED='\033[31m'
YELLOW='\033[33m'
GREEN='\033[32m'
command_exists() {
which $1 >/dev/null 2>&1
}
checkEnv() { checkEnv() {
checkCommandRequirements 'curl groups sudo' checkCommandRequirements 'curl groups sudo'
checkPackageManager 'apt-get dnf pacman zypper nix-env' checkPackageManager 'apt-get dnf pacman zypper nix-env'
@ -21,13 +12,13 @@ setupKitty() {
if ! command_exists kitty; then if ! command_exists kitty; then
case ${PACKAGER} in case ${PACKAGER} in
pacman) pacman)
sudo ${PACKAGER} -S --noconfirm kitty sudo $"{PACKAGER}" -S --noconfirm kitty
;; ;;
nix-env) nix-env)
sudo ${PACKAGER} -iA nixos.kitty sudo $"{PACKAGER}" -iA nixos.kitty
;; ;;
*) *)
sudo ${PACKAGER} install -y kitty sudo "${PACKAGER}" install -y kitty
;; ;;
esac esac
else else
@ -35,11 +26,11 @@ setupKitty() {
fi fi
echo "Copy Kitty config files" echo "Copy Kitty config files"
if [ -d "${HOME}/.config/kitty" ]; then if [ -d "${HOME}/.config/kitty" ]; then
cp -r ${HOME}/.config/kitty ${HOME}/.config/kitty-bak cp -r "${HOME}"/.config/kitty "${HOME}"/.config/kitty-bak
fi fi
mkdir -p ${HOME}/.config/kitty/ mkdir -p "${HOME}"/.config/kitty/
wget -O ${HOME}/.config/kitty/kitty.conf https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/kitty.conf wget -O "${HOME}"/.config/kitty/kitty.conf https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/kitty.conf
wget -O ${HOME}/.config/kitty/nord.conf https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/nord.conf wget -O "${HOME}"/.config/kitty/nord.conf https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/nord.conf
} }
checkEnv checkEnv

View File

@ -1,14 +1,5 @@
#!/bin/sh -e #!/bin/sh -e
RC='\033[0m'
RED='\033[31m'
YELLOW='\033[33m'
GREEN='\033[32m'
command_exists() {
which "$1" >/dev/null 2>&1
}
checkEnv() { checkEnv() {
checkCommandRequirements 'curl groups sudo' checkCommandRequirements 'curl groups sudo'
checkPackageManager 'apt-get dnf pacman zypper nix-env' checkPackageManager 'apt-get dnf pacman zypper nix-env'