feat(scripts): have is now x-have script

This commit is contained in:
2023-09-29 14:51:20 +03:00
parent 3d753fe08c
commit 56ae0e1e1c
13 changed files with 23 additions and 13 deletions

10
local/bin/x-have Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bash
# Returns which status
which -s "$1" >&/dev/null
if [ $? -eq 0 ]; then
echo 0
else
echo 1
fi

View File

@@ -6,7 +6,7 @@ source "$HOME/.dotfiles/scripts/shared.sh"
msg "Starting to install rust/cargo packages"
! have cargo && {
[[ $(x-have "cargo") == "1" ]] && {
msg "cargo could not be found. installing cargo with rustup.rs"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path
}

View File

@@ -6,7 +6,7 @@ source "$HOME/.dotfiles/scripts/shared.sh"
PBB_REQUIRED_TOOLS=(git cheat)
for t in ${PBB_REQUIRED_TOOLS[@]}; do
! have "$t" && echo "(!) $t is missing, can't continue..." && exit 1
[[ $(x-have "$t") == "1" ]] && echo "(!) $t is missing, can't continue..." && exit 1
done
PBB_GIT="https://github.com/dylanaraps/pure-bash-bible.git"

View File

@@ -6,7 +6,7 @@ source "$HOME/.dotfiles/scripts/shared.sh"
TLDR_REQUIRED_TOOLS=(git cheat)
for t in ${TLDR_REQUIRED_TOOLS[@]}; do
! have "$t" && echo "(!) $t is missing, can't continue..." && exit 1
[[ $(x-have "$t") == "1" ]] && echo "(!) $t is missing, can't continue..." && exit 1
done
TLDR_GIT="https://github.com/tldr-pages/tldr.git"

View File

@@ -4,7 +4,7 @@
# shellcheck source="shared.sh"
source "$HOME/.dotfiles/scripts/shared.sh"
! have php && msg_err "PHP Not Available, cannot install composer" && exit 0
[[ $(x-have "php") == "1" ]] && msg_err "PHP Not Available, cannot install composer" && exit 0
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

View File

@@ -6,7 +6,7 @@ source "$HOME/.dotfiles/scripts/shared.sh"
msg_run "Installing gh (GitHub Client) extensions"
! have gh \
[[ $(x-have "gh") == "1" ]] \
&& msg_err "gh (GitHub Client) could not be found, please install it first" \
&& exit 0

View File

@@ -8,7 +8,7 @@ source "$HOME/.dotfiles/scripts/shared.sh"
msg_run "Installing git-crypt"
! have git-crypt && {
[[ $(x-have "git-crypt") == "1" ]] && {
REPO_URL="https://github.com/AGWA/git-crypt.git"
CHECK_PATH="${XDG_BIN_HOME}/git-crypt"

View File

@@ -6,7 +6,7 @@ source "$HOME/.dotfiles/scripts/shared.sh"
msg_run "Installing go packages"
! have go && msg "go hasn't been installed yet." && exit 0
[[ $(x-have "go") == "1" ]] && msg "go hasn't been installed yet." && exit 0
packages=(
# A shell parser, formatter, and interpreter with bash support; includes shfmt

View File

@@ -11,7 +11,7 @@ NEOFETCH_URL="${NEOFETCH_REPO}/archive/refs/tags/${NEOFETCH_VERSION}.tar.gz"
NEOFETCH_TEMP="/tmp/neofetch"
NEOFETCH_INSTALL_PREFIX="$HOME/.local"
have neofetch || {
[[ $(x-have "neofetch") == "1" ]] && {
LC_ALL=C
mkdir -p "$NEOFETCH_TEMP" "$NEOFETCH_INSTALL_PREFIX"

View File

@@ -6,7 +6,7 @@ source "$HOME/.dotfiles/scripts/shared.sh"
msg "Starting to install npm packages"
! have npm && msg_err "npm could not be found." && exit 0
[[ $(x-have "npm") == "1" ]] && msg_err "npm could not be found." && exit 0
packages=(
# This is a tool to check if your files consider your .editorconfig rules.

View File

@@ -6,7 +6,7 @@
source "$HOME/.dotfiles/scripts/shared.sh"
set -e
have ntfy && msg "ntfy already installed" && exit 0
[[ $(x-have "ntfy") == "0" ]] && msg "ntfy already installed" && exit 0
case $(dfm check arch) in
Linux)

View File

@@ -6,8 +6,8 @@ source "$HOME/.dotfiles/scripts/shared.sh"
msg "Starting to install pip packages"
! have python3 && {
msg_err "Could not find python3, something really terrible is going on." && exit 1
[[ $(x-have "python3") == "1" ]] && {
msg_err "Could not find python3, something really weird is going on." && exit 1
}
packages=(

View File

@@ -92,7 +92,7 @@ function have_command
# usage: have php && php -v
function have
{
bkt -- which -s "$1" >&/dev/null
bkt -- which "$1" >&/dev/null
}
function brew_installed