macos 我可以在 Mac 的终端中编辑一些东西吗
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9012882/
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
Can I gedit something in Mac's Terminal
提问by Xi Zhang
When I was using a Linux laptop as my dev machine, I used to do "gedit xxxx" in a Terminal. Now I just switched to MacBook, I d like to do the same thing.
当我使用 Linux 笔记本电脑作为我的开发机器时,我曾经在终端中执行“gedit xxxx”。现在我刚刚切换到 MacBook,我想做同样的事情。
I know that I can open gedit in a command line like "open gedit", but can I add the file name? Otherwise I have to use vim. I am not a fan of vim.
我知道我可以在像“open gedit”这样的命令行中打开 gedit,但是我可以添加文件名吗?否则我必须使用vim。我不是vim的粉丝。
采纳答案by jwalk
Add
添加
alias gedit="open -a gedit"
alias gedit="open -a gedit"
to ~/.bash_profile
:
到~/.bash_profile
:
Now you'll be able to gedit directly from the command line.
现在您将能够直接从命令行进行 gedit。
回答by prodigitalson
try:
尝试:
open -a /path/to/gedit /path/to/file.txt
回答by dandelion
I added the following to my PATH:
我在 PATH 中添加了以下内容:
:~/Applications/gedit.app/Contents/MacOS/
and afterwards I was able to access gedit from the command line. One caveat: if gedit is not already running on the system, then it throws an error if I launch it from the command line. Once gedit is already running though, this works to open files in gedit from the command line.
之后我可以从命令行访问 gedit。一个警告:如果 gedit 尚未在系统上运行,那么如果我从命令行启动它,它会引发错误。一旦 gedit 已经运行,这可以从命令行在 gedit 中打开文件。
To edit the path, open ~/.profile in an editor
要编辑路径,请在编辑器中打开 ~/.profile
回答by Quasar
I use textmate for dev, here is a tutorial how it is done for Textmate
我使用 textmate 进行开发,这是如何为 Textmate 完成的教程
http://manual.macromates.com/en/using_textmate_from_terminal.html
http://manual.macromates.com/en/using_textmate_from_terminal.html
I believe the same would apply to gedit.
我相信这同样适用于 gedit。
Hope it helps
希望能帮助到你