我想在 Xcode 中打开文件,我用它来开发,也在我的冲突解决过程中使用
git-mediate -e
。是否有一个命令行命令可以在 EDITOR
环境变量中设置,该命令将调用 Xcode 来编辑给定文件? (奖励:也在指定行)
要从命令行打开 Xcode 中的特定文件,请使用
open -a /Applications/Xcode.app
例如:
open -a /Applications/Xcode.app your_file_name.txt
为了能够用作
EDITOR
,请将其包装在脚本中 xcode-edit.sh
:
#!/bin/sh
open -a /Applications/Xcode.app $@
现在,您可以使用
EDITOR=xcode-edit.sh git-mediate -e
如果你安装了Xcode的命令行工具,你就有了
xed
% which xed
/usr/bin/xed
% xed --help
Options:
-c, --create Create the files if they do not exist.
-p, --project <path> Open the project, workspace, or package at <path> before opening the requsted files.
-w, --wait Wait for file to be closed by Xcode before terminating xed.
-l, --line <number> Select line <number> after opening file.
-b, --background Leave Xcode in the background (don't activate it).
-h, --help Show this information.
-v, --version Print version information.
所以以下就是你想要的
export EDITOR="xed -w"