macos 将 TextMate 设置为 Mac OS X 上的默认文本编辑器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9370584/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Set TextMate as the default text editor on Mac OS X
提问by Ben
How can I set TextMate as default text editor on Mac OS X?
如何在 Mac OS X 上将 TextMate 设置为默认文本编辑器?
I've tried it with
我试过了
ln -s /Applications/TextMate.app/Contents/Resources/mate ~/bin/mate
export EDITOR='mate -w'
but that doesn't work.
但这不起作用。
回答by Timeout
Just right (or control) click a file of the type you want to change and:
恰到好处(或控制)单击您要更改的类型的文件,然后:
"Get Info" -> "Open with:" -> (Select TextMate) -> "Change All"
“获取信息”->“打开方式:”->(选择TextMate)->“全部更改”
回答by KFunk
The method through Finder is not practical. If you're a developer, your files likely include .profile, .gitconfig, .bashrc, .bash_profile, .htdocs, etc.
通过 Finder 的方法并不实用。如果您是开发人员,您的文件可能包括 .profile、.gitconfig、.bashrc、.bash_profile、.htdocs 等。
The best way to do this is in Bash (for Sublime Text 3):
最好的方法是在 Bash 中(对于 Sublime Text 3):
defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}'
For other text editors, I assume you can replace 'com.sublimetext.3' with the proper string. You could probably Google for your text editor's name + "LSHandlerContentType=public.plain-text" to figure out what your app's string would be.
对于其他文本编辑器,我假设您可以用正确的字符串替换 'com.sublimetext.3'。您可能可以通过 Google 搜索您的文本编辑器的名称 + "LSHandlerContentType=public.plain-text" 来确定您的应用程序的字符串是什么。
For me, this changed the defaults for both Finder, and
对我来说,这改变了 Finder 和
$ open ~/.bashrc
回答by Ned Deily
Have you modified your shell PATH environment variable to include ~/bin
? That directory is usually not included in PATH by default on OS X. It might be simpler to create the symlink in /usr/local/bin
which is usually included in PATH
. Try:
您是否已将 shell PATH 环境变量修改为包含~/bin
?在 OS X 上,默认情况下该目录通常不包含在 PATH 中。创建/usr/local/bin
通常包含在PATH
. 尝试:
echo $PATH
回答by eestrada
To change the default text editor across the board, use the aforementioned method (i.e., "Get Info" → "Open with:" → (editor of choice) → "Change All") on .txt files. Then it will be used as the default editor for any text-based file that doesn't yet have an application preference for its extension.
要全面更改默认文本编辑器,请在.txt 文件上使用上述方法(即“获取信息”→“打开方式:”→(选择的编辑器)→“全部更改”)。然后它将用作任何基于文本的文件的默认编辑器,这些文件的扩展名还没有应用程序首选项。
For instance, if you use the terminal, the command open -t
will use your preferred text editor, which is whatever application is associated with .txt files. By default this is (you guessed it) TextEdit, unless you explicitly specify otherwise.
例如,如果您使用终端,该命令open -t
将使用您首选的文本编辑器,即与 .txt 文件关联的任何应用程序。默认情况下这是(你猜对了)TextEdit,除非你明确指定。
回答by SteveCoffman
This worked for me on OS X v10.11 (El Capitan):
这在 OS X v10.11 (El Capitan) 上对我有用:
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add \
'{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.macromates.textmate.preview;}'
回答by Anton Plebanovich
For TextMate 2:
对于 TextMate 2:
defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.macromates.TextMate;}'
And you need to restart after that.
之后你需要重新启动。