From caa0d48c6058037181fc895369d998e723ef142b Mon Sep 17 00:00:00 2001 From: John D Pell Date: Thu, 30 Dec 2021 12:16:37 -0800 Subject: [PATCH] plugin/osx: move `$OSTYPE` check to top of file --- plugins/available/osx.plugin.bash | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/plugins/available/osx.plugin.bash b/plugins/available/osx.plugin.bash index 532717a7..139f58a1 100644 --- a/plugins/available/osx.plugin.bash +++ b/plugins/available/osx.plugin.bash @@ -1,6 +1,11 @@ # shellcheck shell=bash about-plugin 'osx-specific functions' +if [[ "${OSTYPE}" != 'darwin'* ]]; then + _log_warning "This plugin only works with Mac OS X." + return 1 +fi + # OS X: Open new tabs in same directory if _is_function update_terminal_cwd; then safe_append_prompt_command 'update_terminal_cwd' @@ -53,10 +58,6 @@ function prevcurl() { param '1: url' group 'osx' - if [[ ! $OSTYPE = 'darwin'* ]]; then - echo "This function only works with Mac OS X" - return 1 - fi curl "$*" | open -fa 'Preview' } @@ -65,12 +66,8 @@ function refresh-launchpad() { example '$ refresh-launchpad' group 'osx' - if [[ "$OSTYPE" = 'darwin'* ]]; then - defaults write com.apple.dock ResetLaunchPad -bool TRUE - killall Dock - else - echo "Sorry, this only works on Mac OS X" - fi + defaults write com.apple.dock ResetLaunchPad -bool TRUE + killall Dock } function list-jvms() {