从 bash 在默认编辑器中打开文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/13627767/
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
Open file in default editor from bash
提问by Jawap
How do I open a file my script generated with the default GUI editor with bash?
如何使用 bash 打开使用默认 GUI 编辑器生成的脚本文件?
On OS X there is the command open, but as far as I know that doesn't exist on linux. What is a good cross-platform alternative?
在 OS X 上有 command open,但据我所知在 linux 上不存在。什么是好的跨平台替代方案?
(executing open somefile.exton OS X does the same as if I double clicked the file in Finder).
(open somefile.ext在 OS X 上执行就像我在 Finder 中双击文件一样)。
回答by Antoine
On linux you have kde-openand gnome-openfor specific desktop environments, and xdg-openis more generic but must still be run from a DE.
在Linux上你必须kde-open和gnome-open特定的桌面环境,而且xdg-open是更通用的,但仍必须从DE运行。
On windows, (obviously not bashbut cmd.exe), I believe the similar command is start.
在 Windows 上(显然不是bash但是cmd.exe),我相信类似的命令是start.
With bash a cross-platform code could be:
使用 bash 的跨平台代码可以是:
if which xdg-open &> /dev/null; then
    xdg-open $file       # linux
else
    open $file           # mac
fi
回答by Kamber
On your .profile
在您的 .profile 上
export EDITOR='~/bin/mate -w'
导出编辑器='~/bin/mate -w'
and your bash use this editor
你的 bash 使用这个编辑器

