0

我想打开我所有的 html/css/js 等,而不是通过键入在浏览器中open example.html,而是使用我的默认编辑器。我确实alias EDITOR已经创建了,但它不适用于每种文件。

如何解决?

4

3 回答 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.
于 2013-06-15T14:51:29.090 回答
1

如果你使用 TextMate 或 Sublime Text,你可以使用matesubl。您可以为其他编辑器创建这样的别名:

alias wrang="open -a TextWrangler"

open -t在文件的默认应用程序中打开public.plain-text文件。您可以通过在duti配置文件中添加这样的行来更改它:

com.macromates.TextMate.preview public.plain-text all
于 2013-06-15T17:15:18.133 回答
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

于 2013-06-15T14:54:53.577 回答