#!/bin/sh ## # from: https://gist.github.com/railwaycat/4043945 ## emacs_app=/usr/local/opt/emacs-mac/Emacs.app if [ ! -x $emacs_app ]; then echo "Emacs.app not found" >&2 exit 1 fi /usr/bin/osascript -e "tell application \"$emacs_app\" to activate" & if [ $# -gt 0 ]; then tempfiles=() while IFS= read -r filename; do if [ ! -f "$filename" ]; then tempfiles+=("$filename") /usr/bin/touch "$filename" fi file=$(echo $(cd $(dirname "$filename") && pwd -P)/$(basename "$filename")) /usr/bin/osascript -e "tell application \"$emacs_app\" to open POSIX file \"$file\"" done <<< "$(printf '%s\n' "$@")" for tempfile in "${tempfiles[@]}"; do [ ! -s "$tempfile" ] && /bin/rm "$tempfile" done fi &