我已经安装了MacVim,我正试图将其设置为Git(版本控制)的编辑器,但我不能从命令行运行“mvim”,因为它不被识别。我如何设置mvim,以便我可以从终端运行它?
当前回答
对于Mac .app包,如果可用,您应该通过cask安装它们,因为使用符号链接可能会导致问题。你甚至可能会得到以下警告,如果你酿造linkapps:
不幸的是,brew linkapps不能很好地与聚光灯使用 别名或符号链接和自制公式都不能构建“适当的”.app 可以重新定位的包。相反,请考虑使用酿造桶和 使用.apps将公式迁移到桶中。
对于MacVim,您可以安装:
brew cask install macvim
然后,您应该能够像启动任何其他macOS应用程序一样启动MacVim,包括mvim或从终端会话打开-a MacVim。
UPDATE: A bit of clarification about brew and brew cask. In a nutshell, brew handles software at the unix level, whereas brew cask extends the functionality of brew into the macOS domain for additional functionality such as handling the location of macOS app bundles. Remember that brew is also implemented on Linux so it makes sense to have this division. There are other resources that explain the difference in more detail, such as What is the difference between brew and brew cask? so I won't say much more here.
其他回答
我强烈建议通过MacPorts安装MacVim (sudo port install MacVim)。
当安装时,MacPorts会自动更新你的配置文件以包含/opt/local/bin在你的路径中,所以当mvim在安装MacVim期间被安装为/opt/local/bin/mvim时,你会发现它可以直接使用。
当你安装MacVim端口时,MacVim。app bundle也安装在/Applications/MacPorts中。
走MacPorts路线的一个好处是,你也可以安装git (sudo port install git-core)和许多其他端口。强烈推荐。
如果你安装了homeBrew,这就是你所要做的:
brew install macvim
brew linkapps
然后在终端中输入mvim来运行MacVim。
这对我来说很管用:
λ brew link --overwrite macvim
Linking /usr/local/Cellar/macvim/8.0-146_1... 12 symlinks created
In addition, if you want to use MacVim (or GVim) as $VISUAL or $EDITOR, you should be aware that by default MacVim will fork a new process from the parent, resulting in the MacVim return value not reaching the parent process. This may confuse other applications, but Git seems to check the status of a temporary commit message file, which bypasses this limitation. In general, it is a good practice to export VISUAL='mvim -f' to ensure MacVim will not fork a new process when called, which should give you what you want when using it with your shell environment.
对于Mac .app包,如果可用,您应该通过cask安装它们,因为使用符号链接可能会导致问题。你甚至可能会得到以下警告,如果你酿造linkapps:
不幸的是,brew linkapps不能很好地与聚光灯使用 别名或符号链接和自制公式都不能构建“适当的”.app 可以重新定位的包。相反,请考虑使用酿造桶和 使用.apps将公式迁移到桶中。
对于MacVim,您可以安装:
brew cask install macvim
然后,您应该能够像启动任何其他macOS应用程序一样启动MacVim,包括mvim或从终端会话打开-a MacVim。
UPDATE: A bit of clarification about brew and brew cask. In a nutshell, brew handles software at the unix level, whereas brew cask extends the functionality of brew into the macOS domain for additional functionality such as handling the location of macOS app bundles. Remember that brew is also implemented on Linux so it makes sense to have this division. There are other resources that explain the difference in more detail, such as What is the difference between brew and brew cask? so I won't say much more here.
推荐文章
- Linux相当于Mac OS X的“open”命令
- 如何在Mac上的命令行安装JQ ?
- 在Mac OS X上安装/升级gradle
- Vim:在可视模式下快速选择文本块的方法
- 如何在终端中提高光标速度?
- 在命令行中使用Firefox截取完整页面的截图
- 在pip install -U中“-U”选项代表什么
- Objective-C中的自动引用计数不能防止或减少什么样的泄漏?
- 如何将参数转发到bash脚本中的其他命令?
- 文件中最长的一行
- 如何在Mac OS安装时停止MySQL ?
- [: shell编程中的意外操作符
- 如何在变量中存储标准错误
- PIP成功安装包,但在命令行中找不到可执行文件
- 无法在Mac OS X 10.9上安装Lxml