Created
May 14, 2020 07:03
-
-
Save rs77/75111bfd001dddc8a61a213ea389ed03 to your computer and use it in GitHub Desktop.
Coda shell script to open file in Coda
This file contains 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 | |
# Coda from the command line | |
# Version 1.0 | |
# | |
# Open Coda or open files in Coda from the command line | |
# | |
# (C) Noah Frederick 2011 <http://noahfrederick.com> | |
# | |
# Version 1.1 | |
# point codapath to Coda 2.app | |
# make coda default editor with open command | |
# create alias for 'coda' | |
###################### CONFIG ###################### | |
# Path to Coda.app | |
codapath="/Applications/Coda 2.app" | |
#################################################### | |
# make default editor | |
export EDITOR="$codapath -w" | |
# create 'coda' alias | |
alias coda=open_with_coda | |
# open_with_coda (): | |
# Open any number of files with Coda.app | |
# Files that don't exist will be created | |
open_with_coda () { | |
for arg in "$@" | |
do | |
if [ ! -f "$arg" ] ; then | |
touch "$arg" | |
fi | |
done | |
open -a "$codapath" "$@" | |
} | |
# open_coda (): | |
# Launch Coda.app | |
open_coda () { | |
open "$codapath" | |
} | |
# display_help (): | |
# Show a helpful usage message | |
display_help () { | |
echo "usage: $0 [--help|-h] [<file> ...]" | |
echo | |
echo '\t--help|-h show this message' | |
echo '\t<file> file will be opened in Coda.app' | |
echo '\t (omit to launch Coda.app)' | |
echo | |
} | |
#################################################### | |
if [ $# -gt 0 ]; then | |
case "$1" in | |
--help|-h) | |
display_help | |
;; | |
*) | |
open_with_coda "$@" | |
;; | |
esac | |
else | |
open_coda | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment