From: Jesus de Mula Cano Date: Sun, 6 Mar 2011 23:02:43 +0000 (+0100) Subject: Add command_exists function to base.plugin from http://stackoverflow.com/questions... X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=229aa833a2965581f549fceddc78e28317c53e63;p=common%2Fbash_it.git Add command_exists function to base.plugin from stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script: --- diff --git a/plugins/base.plugin.bash b/plugins/base.plugin.bash index 7f4ba2f..3a73b30 100644 --- a/plugins/base.plugin.bash +++ b/plugins/base.plugin.bash @@ -11,19 +11,11 @@ function myip { echo "Your public IP is: ${bold_green} $res ${normal}" } -# Make a directory and immediately 'cd' into it - function mkcd(){ mkdir -p "$*" cd "$*" } -# Search through directory contents with grep - -function lsgrep(){ - ls | grep "$*" -} - # View man documentation in Preview pman () { man -t "${1}" | open -f -a $PREVIEW @@ -77,6 +69,11 @@ function t() { fi } +# Checks for existence of a command +command_exists () { + type "$1" &> /dev/null ; +} + # List all plugins and functions defined by bash-it function plugins-help() {