From fc21785264704f315320db3f4a159dfbecdb1a50 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 18 Oct 2013 09:53:01 -0400 Subject: [PATCH] Check if homebrew is installed before making functions for it --- zsh/lib/os | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/zsh/lib/os b/zsh/lib/os index 87e7147d..301b7b53 100644 --- a/zsh/lib/os +++ b/zsh/lib/os @@ -12,17 +12,38 @@ function is_linux { if is_mac; then - function pkg_install() { - brew install $1 - } + if command_exists brew; then - function pkg_remove() { - brew remove $1 - } + function pkg_install() { + brew install $1 + } - function pkg_update() { - brew update && brew upgrade - } + function pkg_remove() { + brew remove $1 + } + + function pkg_update() { + brew update && brew upgrade + } + + else + + function pkg_install() { + echo_r "Homebrew not installed" + exit 1 + } + + function pkg_remove() { + echo_r "Homebrew not installed" + exit 1 + } + + function pkg_update() { + echo_r "Homebrew not installed" + exit 1 + } + + fi elif is_deb; then