diff --git a/git/install.sh b/git/install.sh index a063b42..4998b95 100644 --- a/git/install.sh +++ b/git/install.sh @@ -4,20 +4,21 @@ set -u __init_git() { - if [ -z "$(command -v git)" ]; then - if [ "Darwin" = "$(uname -s)" ]; then - echo >&2 "Error: 'git' not found. You may have to re-install 'git' on Mac after every major update." - echo >&2 " for example, try: xcode-select --install" - # sudo xcodebuild -license accept - else - echo >&2 "Error: to install 'git' on Linux use the built-in package manager." - echo >&2 " for example, try: sudo apt install -y git" - fi - exit 1 - else + if command -v git > /dev/null; then echo "'git' already installed" + return 0 fi + if [ "Darwin" = "$(uname -s)" ]; then + echo >&2 "Error: 'git' not found. You may have to re-install 'git' on Mac after every major update." + echo >&2 " for example, try: xcode-select --install" + # sudo xcodebuild -license accept + else + echo >&2 "Error: to install 'git' on Linux use the built-in package manager." + echo >&2 " for example, try: sudo apt install -y git" + fi + + exit 1 } __init_git diff --git a/pyenv/install.sh b/pyenv/install.sh index 6f67147..2ba8ef7 100644 --- a/pyenv/install.sh +++ b/pyenv/install.sh @@ -17,7 +17,7 @@ __init_pyenv() { } >> ~/.bashrc fi - if [ -n "$(command -v zsh)" ]; then + if command -v zsh > /dev/null; then touch ~/.zshrc if ! grep -q 'pyenv init' ~/.zshrc; then { @@ -31,7 +31,7 @@ __init_pyenv() { fi fi - if [ -n "$(command -v fish)" ]; then + if command -v fish > /dev/null; then mkdir -p ~/.config/fish touch ~/.config/fish/config.fish if ! grep -q 'pyenv init' ~/.config/fish/config.fish; then diff --git a/sudo/install.sh b/sudo/install.sh index 671a1f4..4f7c33a 100644 --- a/sudo/install.sh +++ b/sudo/install.sh @@ -4,14 +4,20 @@ set -u __init_sudo() { - if [ -z "$(command -v sudo)" ]; then - echo >&2 "Error: on Linux and BSD you should install sudo via the native package manager" - echo >&2 " for example: apt install -y sudo" - exit 1 - else + if command -v sudo > /dev/null; then echo "'sudo' already installed" + exit 0 fi + echo >&2 "Error: on Linux & BSD use the native package manager to install sudo:" + echo >&2 " For Ubuntu / Debian:" + echo >&2 " apt install -y sudo" + echo >&2 "" + echo >&2 " For Alpine / Docker:" + echo >&2 " apk add sudo" + echo >&2 "" + + exit 1 } __init_sudo diff --git a/vim-beyondcode/install.sh b/vim-beyondcode/install.sh index 0c517d0..24e427f 100644 --- a/vim-beyondcode/install.sh +++ b/vim-beyondcode/install.sh @@ -22,7 +22,7 @@ __init_vim_beyondcode() { nerdfont \ vim-devicons - if [ -n "$(command -v go)" ]; then + if command -v go > /dev/null; then "$HOME/.local/bin/webi" vim-go fi # done diff --git a/vim-prettier/install.sh b/vim-prettier/install.sh index d26c6a1..e67ee9d 100644 --- a/vim-prettier/install.sh +++ b/vim-prettier/install.sh @@ -8,7 +8,7 @@ __init_vim_prettier() { rm -rf "$HOME/.vim/pack/plugins/start/vim-prettier" git clone --depth=1 https://github.com/prettier/vim-prettier.git "$HOME/.vim/pack/plugins/start/vim-prettier" - if [ -z "$(command -v node)" ]; then + if ! command -v node > /dev/null; then export PATH="$HOME/.local/opt/node/bin:$HOME/.local/bin:${PATH}" "$HOME/.local/bin/webi" node fi diff --git a/vim-shfmt/install.sh b/vim-shfmt/install.sh index 350b6a2..1d8949b 100644 --- a/vim-shfmt/install.sh +++ b/vim-shfmt/install.sh @@ -9,10 +9,10 @@ __init_vim_shfmt() { git clone --depth=1 https://github.com/z0mbix/vim-shfmt.git "$HOME/.vim/pack/plugins/start/vim-shfmt" export PATH="$HOME/.local/bin:${PATH}" - if [ -z "$(command -v shfmt)" ]; then + if ! command -v shfmt > /dev/null; then "$HOME/.local/bin/webi" shfmt fi - if [ -z "$(command -v shellcheck)" ]; then + if ! command -v shellcheck > /dev/null; then "$HOME/.local/bin/webi" shellcheck fi