#!/usr/bin/env bash # shellcheck shell=bash # vim: filetype=zsh # Cache commands using bkt if installed if command -v bkt >&/dev/null; then bkt() { command bkt --cache-dir="$XDG_CACHE_HOME/bkt" "$@" } else # If bkt isn't installed skip its arguments and just execute directly. # Optionally write a msg to stderr suggesting users install bkt. bkt() { while [[ "$1" == --* ]]; do shift; done "$@" } fi # shorthand for checking if the system has the bin in path, # this version does not use caching # usage: have_command php && php -v have_command() { command -v "$1" >&/dev/null } # shorthand for checking if the system has the bin in path, # this version uses caching # usage: have php && php -v have() { bkt -- which "$1" >&/dev/null } # function to run dark-notify and change alacritty theme # it uses flock to prevent running multiple instances # install flock with `brew install flock` on macOS function darknotify_alacritty { have flock && [[ -f /tmp/dark-notify-alacritty.lock ]] && return have dark-notify && { # true is used to prevent the command show it was backgrounded true \ && flock /tmp/dark-notify-alacritty.lock dark-notify -c "$HOME/.dotfiles/local/bin/x-change-alacritty-theme" & } return 0 } darknotify_alacritty brew_installed() { bkt -- brew list } # shorthand for checking if brew package is installed # usage: have_brew php && php -v have_brew() { ! x-have brew && return 125 if bkt -- brew list "$1" &> /dev/null; then return 0 else return 1 fi } if [[ -f "$DOTFILES/config/exports-secret" ]]; then source "$DOTFILES/config/exports-secret" fi source "$DOTFILES/config/exports-shell" source "$DOTFILES/config/exports-apps"