Skip to content

Commit

Permalink
refactor: rename has to command_exists
Browse files Browse the repository at this point in the history
  • Loading branch information
pandanoir committed Feb 7, 2025
1 parent b265cd8 commit 5b7c171
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
set -eu

ARG1="$([ $# -eq 1 ] && echo "$1" || echo "")"
has() { type "$1" > /dev/null 2>&1; }
command_exists() { type "$1" >/dev/null 2>&1; }
file_exists() { [ -f $1 ]; }
dir_exists() { [ -d $1 ]; }
is_update_mode() { [ "$ARG1" = "update" ] || [ "$ARG1" = "-u" ]; }
Expand All @@ -19,7 +19,7 @@ DOTDIR="$HOME/dotfiles"
: "${XDG_DATA_HOME:="$HOME/.local/share"}"
: "${ZDOTDIR:="$XDG_CONFIG_HOME/zsh"}"

if ! has git; then
if ! command_exists git; then
warn "you must install git!"
exit 1
fi
Expand Down
6 changes: 3 additions & 3 deletions scripts/check_requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ check_requirements() {
info "check requirements..."

local is_every_requirement_met=true
if ! has nvim && ! file_exists "$HOME/local/nvim/bin/nvim"; then
if ! command_exists nvim && ! file_exists "$HOME/local/nvim/bin/nvim"; then
warn "you must install neovim! please see installing-neovim : https://github.com/neovim/neovim/wiki/Installing-Neovim"
is_every_requirement_met=false
fi
Expand All @@ -18,7 +18,7 @@ check_requirements() {
cd -
fi

if ! has zsh; then
if ! command_exists zsh; then
warn "zsh isn't installed"
is_every_requirement_met=false
else
Expand All @@ -33,7 +33,7 @@ check_requirements() {
fi
fi

if ! has tmux; then
if ! command_exists tmux; then
warn "tmux isn't installed"
is_every_requirement_met=false
else
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ deploy() {
symlink starship.toml "$XDG_CONFIG_HOME/starship.toml"
mkdir -p "$XDG_DATA_HOME/rustup"

if has ranger && ! dir_exists "$DOTDIR/ranger/plugins/ranger_devicons"; then
if command_exists ranger && ! dir_exists "$DOTDIR/ranger/plugins/ranger_devicons"; then
git clone https://github.com/alexanderjeurissen/ranger_devicons "$DOTDIR/ranger/plugins/ranger_devicons"
cd "$DOTDIR/ranger/plugins/ranger_devicons"
make install
Expand Down

0 comments on commit 5b7c171

Please sign in to comment.