mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-10 14:51:50 +00:00
feat(scripts): have is now x-have script
This commit is contained in:
10
local/bin/x-have
Executable file
10
local/bin/x-have
Executable 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
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ source "$HOME/.dotfiles/scripts/shared.sh"
|
|||||||
|
|
||||||
msg "Starting to install rust/cargo packages"
|
msg "Starting to install rust/cargo packages"
|
||||||
|
|
||||||
! have cargo && {
|
[[ $(x-have "cargo") == "1" ]] && {
|
||||||
msg "cargo could not be found. installing cargo with rustup.rs"
|
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
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ source "$HOME/.dotfiles/scripts/shared.sh"
|
|||||||
|
|
||||||
PBB_REQUIRED_TOOLS=(git cheat)
|
PBB_REQUIRED_TOOLS=(git cheat)
|
||||||
for t in ${PBB_REQUIRED_TOOLS[@]}; do
|
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
|
done
|
||||||
|
|
||||||
PBB_GIT="https://github.com/dylanaraps/pure-bash-bible.git"
|
PBB_GIT="https://github.com/dylanaraps/pure-bash-bible.git"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ source "$HOME/.dotfiles/scripts/shared.sh"
|
|||||||
|
|
||||||
TLDR_REQUIRED_TOOLS=(git cheat)
|
TLDR_REQUIRED_TOOLS=(git cheat)
|
||||||
for t in ${TLDR_REQUIRED_TOOLS[@]}; do
|
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
|
done
|
||||||
|
|
||||||
TLDR_GIT="https://github.com/tldr-pages/tldr.git"
|
TLDR_GIT="https://github.com/tldr-pages/tldr.git"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# shellcheck source="shared.sh"
|
# shellcheck source="shared.sh"
|
||||||
source "$HOME/.dotfiles/scripts/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");')"
|
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
|
||||||
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ source "$HOME/.dotfiles/scripts/shared.sh"
|
|||||||
|
|
||||||
msg_run "Installing gh (GitHub Client) extensions"
|
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" \
|
&& msg_err "gh (GitHub Client) could not be found, please install it first" \
|
||||||
&& exit 0
|
&& exit 0
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ source "$HOME/.dotfiles/scripts/shared.sh"
|
|||||||
|
|
||||||
msg_run "Installing git-crypt"
|
msg_run "Installing git-crypt"
|
||||||
|
|
||||||
! have git-crypt && {
|
[[ $(x-have "git-crypt") == "1" ]] && {
|
||||||
|
|
||||||
REPO_URL="https://github.com/AGWA/git-crypt.git"
|
REPO_URL="https://github.com/AGWA/git-crypt.git"
|
||||||
CHECK_PATH="${XDG_BIN_HOME}/git-crypt"
|
CHECK_PATH="${XDG_BIN_HOME}/git-crypt"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ source "$HOME/.dotfiles/scripts/shared.sh"
|
|||||||
|
|
||||||
msg_run "Installing go packages"
|
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=(
|
packages=(
|
||||||
# A shell parser, formatter, and interpreter with bash support; includes shfmt
|
# A shell parser, formatter, and interpreter with bash support; includes shfmt
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ NEOFETCH_URL="${NEOFETCH_REPO}/archive/refs/tags/${NEOFETCH_VERSION}.tar.gz"
|
|||||||
NEOFETCH_TEMP="/tmp/neofetch"
|
NEOFETCH_TEMP="/tmp/neofetch"
|
||||||
NEOFETCH_INSTALL_PREFIX="$HOME/.local"
|
NEOFETCH_INSTALL_PREFIX="$HOME/.local"
|
||||||
|
|
||||||
have neofetch || {
|
[[ $(x-have "neofetch") == "1" ]] && {
|
||||||
LC_ALL=C
|
LC_ALL=C
|
||||||
|
|
||||||
mkdir -p "$NEOFETCH_TEMP" "$NEOFETCH_INSTALL_PREFIX"
|
mkdir -p "$NEOFETCH_TEMP" "$NEOFETCH_INSTALL_PREFIX"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ source "$HOME/.dotfiles/scripts/shared.sh"
|
|||||||
|
|
||||||
msg "Starting to install npm packages"
|
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=(
|
packages=(
|
||||||
# This is a tool to check if your files consider your .editorconfig rules.
|
# This is a tool to check if your files consider your .editorconfig rules.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
source "$HOME/.dotfiles/scripts/shared.sh"
|
source "$HOME/.dotfiles/scripts/shared.sh"
|
||||||
set -e
|
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
|
case $(dfm check arch) in
|
||||||
Linux)
|
Linux)
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ source "$HOME/.dotfiles/scripts/shared.sh"
|
|||||||
|
|
||||||
msg "Starting to install pip packages"
|
msg "Starting to install pip packages"
|
||||||
|
|
||||||
! have python3 && {
|
[[ $(x-have "python3") == "1" ]] && {
|
||||||
msg_err "Could not find python3, something really terrible is going on." && exit 1
|
msg_err "Could not find python3, something really weird is going on." && exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
packages=(
|
packages=(
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ function have_command
|
|||||||
# usage: have php && php -v
|
# usage: have php && php -v
|
||||||
function have
|
function have
|
||||||
{
|
{
|
||||||
bkt -- which -s "$1" >&/dev/null
|
bkt -- which "$1" >&/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
function brew_installed
|
function brew_installed
|
||||||
|
|||||||
Reference in New Issue
Block a user