# Functions for use on computers running MacOS _haveScriptableFinder_() { # DESC: # Determine whether we can script the Finder or not # ARGS: # None # OUTS: # 0 if we can script the Finder # 1 if not local _finder_pid _finder_pid="$(pgrep -f /System/Library/CoreServices/Finder.app | head -n 1)" if [[ (${_finder_pid} -gt 1) && (${STY-} == "") ]]; then return 0 else return 1 fi } _guiInput_() { # DESC: # Ask for user input using a Mac dialog box # ARGS: # $1 (Optional) - Text in dialogue box (Default: Password) # OUTS: # MacOS dialog box output # 1 if no output # CREDIT # https://github.com/herrbischoff/awesome-osx-command-line/blob/master/functions.md if _haveScriptableFinder_; then local _guiPrompt="${1:-Password:}" local _guiInput=$( osascript &>/dev/null <