Skip to content

Instantly share code, notes, and snippets.

@halcyon
Last active June 18, 2016 02:18
Show Gist options
  • Select an option

  • Save halcyon/92e9c25c5b2e6e787c8887871b9f12ed to your computer and use it in GitHub Desktop.

Select an option

Save halcyon/92e9c25c5b2e6e787c8887871b9f12ed to your computer and use it in GitHub Desktop.
Start railwaycat's OSX emacs port from the shell
alias e='/usr/local/bin/emacs'
is_arg_p() {
[[ ${1} == $'-'* ]]
}
file_not_found_p() {
[[ ! -f ${1} ]]
}
emacs() {
emacs_args=()
files=()
for token; do
if is_arg_p ${token}
then
emacs_args+=${token}
else
files+=${token}
if file_not_found_p ${token}
then
touch "${token}"
fi
fi
done
if [[ ${#emacs_args[@]} -eq 0 ]]
then
open -a emacs ${files}
else
open -a emacs ${files} --args ${emacs_args}
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment