0

I want to open all of my html/css/js etc. not in the Browser by typing open example.html, but with my default Editor. I did create the alias EDITOR already, but it does not work with every kind of file.

How to fix that?

2
  • 1
    it's not alias, it should be export. EDITOR is an environment variable. Commented Jun 15, 2013 at 13:58
  • 2
    There's the additional problem that open doesn't use EDITOR to choose the editor to open (we're talking about OS X, right? I added that tag). Commented Jun 15, 2013 at 14:03

3 Answers 3

2

Depending on the actual behavior you're looking for, you will probably want one of the following, from the open man page:

 -e  Causes the file to be opened with /Applications/TextEdit

 -t  Causes the file to be opened with the default text editor, as deter-
     mined via LaunchServices

 -f  Reads input from standard input and opens the results in the default
     text editor.  End input by sending EOF character (type Control-D).
     Also useful for piping output to open and having it open in the
     default text editor.

 -W  Causes open to wait until the applications it opens (or that were
     already open) have exited.  Use with the -n flag to allow open to
     function as an appropriate app for the $EDITOR environment variable.
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Kevin, that helped a lot.
1

Try reading the man page: man open

I see three options:

  • -a

    -a application
    Specifies the application to use for opening the file

open -a SomeEditor file.html

  • -e

    Causes the file to be opened with /Applications/TextEdit

open -e file.html

  • -t

    Causes the file to be opened with the default text editor, as determined via LaunchServices

open -t file.html

Comments

1

If you use TextMate or Sublime Text, you can use mate or subl. You can create aliases like this for other editors:

alias wrang="open -a TextWrangler"

open -t opens files in the default application for public.plain-text files. You can change it by adding a line like this to a duti configuration file:

com.macromates.TextMate.preview public.plain-text all

1 Comment

I use an alias for that now and I'm very happy with it. For me its just alias s=open -a Sublimetext. That is what I really needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.