Created
December 20, 2023 08:55
-
-
Save mtungusov/7c2d2b7e52b51e98906874fe7adfcfa3 to your computer and use it in GitHub Desktop.
Emacs.app from CLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment