fuma
fuma

Reputation: 5857

bash open .html file not in browser but with $editor

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?

Upvotes: 0

Views: 430

Answers (3)

Lri
Lri

Reputation: 27613

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

Upvotes: 1

demure
demure

Reputation: 7617

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

Upvotes: 1

Kevin
Kevin

Reputation: 56059

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.

Upvotes: 2

Related Questions