Skip to content

Instantly share code, notes, and snippets.

@rs77
Created May 14, 2020 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rs77/75111bfd001dddc8a61a213ea389ed03 to your computer and use it in GitHub Desktop.
Save rs77/75111bfd001dddc8a61a213ea389ed03 to your computer and use it in GitHub Desktop.
Coda shell script to open file in Coda
#!/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