将 TextMate 设置为 Mac OS X 上的默认文本编辑器
如何将 TextMate 设置为 Mac OS X 上的默认文本编辑器?
我已经尝试过,
ln -s /Applications/TextMate.app/Contents/Resources/mate ~/bin/mate
export EDITOR='mate -w'
但那不起作用。
How can I set TextMate as default text editor on Mac OS X?
I've tried it with
ln -s /Applications/TextMate.app/Contents/Resources/mate ~/bin/mate
export EDITOR='mate -w'
but that doesn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
只需右键(或按住 Control 键)单击要更改的类型的文件,然后:
“获取信息”-> “打开方式:”-> (选择TextMate)-> “全部改变”
Just right (or control) click a file of the type you want to change and:
"Get Info" -> "Open with:" -> (Select TextMate) -> "Change All"
通过Finder的方法不太实用。如果您是开发人员,您的文件可能包括 .profile、.gitconfig、.bashrc、.bash_profile、.htdocs 等。
最好的方法是在 Bash 中(对于 Sublime Text 3):
对于其他文本编辑器,我假设您可以用正确的字符串替换“com.sublimetext.3”。您可能可以通过 Google 搜索您的文本编辑器的名称 +“LSHandlerContentType=public.plain-text”来找出您的应用程序的字符串是什么。
对我来说,这改变了 Finder 的默认值,并且
The method through Finder is not practical. If you're a developer, your files likely include .profile, .gitconfig, .bashrc, .bash_profile, .htdocs, etc.
The best way to do this is in Bash (for Sublime Text 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.
For me, this changed the defaults for both Finder, and
您是否修改了 shell PATH 环境变量以包含
~/bin
?默认情况下,该目录通常不包含在 OS X 的 PATH 中。在/usr/local/bin
中创建符号链接可能更简单,它通常包含在PATH
中。尝试: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 inPATH
. Try:这对我在 OS X v10.11 (El Capitan) 上有用:
This worked for me on OS X v10.11 (El Capitan):
对于 TextMate 2:
之后您需要重新启动。
For TextMate 2:
And you need to restart after that.
要全面更改默认文本编辑器,请使用上述方法(即“获取信息”→“打开方式:”→(选择的编辑器)→“更改全部”)在 .txt 文件上。然后,它将用作任何尚未为其扩展名设置应用程序首选项的基于文本的文件的默认编辑器。
例如,如果您使用终端,命令
open -t
将使用您首选的文本编辑器,即与 .txt 文件关联的任何应用程序。默认情况下,这是(您猜对了)TextEdit,除非您另外明确指定。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.
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.我在 apple.stackexchange 上发现将文本编辑器替换为默认文本编辑器,效果非常好。
对于诸如
.gitignore
之类的开发人员类型文件,请使用提供的最后一个选项:根据需要替换编辑器的 CFBundleIdentifier。要找到它,请找到应用程序文件,右键单击并选择“显示包内容”,然后在“内容”文件夹中打开
Info.plist
。 CFBundleIdentifier 应该位于顶部附近...这在 Catalina 上工作。如果/当我更新我的操作系统时,我会更新我的答案。
I found Replace Text Edit as the default text editor on apple.stackexchange which works really well.
For developer-type files like
.gitignore
, use the last option provided:Substitute your editor's CFBundleIdentifier as needed. To find it, locate the application file, right-click and choose Show Package Contents, then open
Info.plist
in the Contents folder. CFBundleIdentifier should be near the top...This work on Catalina. I'll update my answer if/when I update my OS.