如何在 Mac 上恢复 .bash_profile?我的 unix 终端都没有工作
我在尝试将 Playframework 添加到我的路径时向我的 bash_profile 添加了一些东西,但有些东西搞砸了.
I added something to my bash_profile while trying to add Playframework to my path and something got messed up badly.
我将以下行添加到我的 .bash_profile
I added the following line to my .bash_profile
export PATH=$PATH:the path to my play excitable
然后我保存了所有内容并重新启动了我的终端.我不能再从我的终端做任何事情.我无法 cd 进入任何目录,我再也找不到 java,我无法打开 vi 或 nano.我发现 这个 SuperUser 上的帖子建议打开一个不同的终端并更改 bash 配置文件.
then I saved everything and restarted my terminal. I can no longer do anything from my terminal. I can't cd into any directory, I can no longer find java, I can't open vi or nano. I found this thread on SuperUser that suggested opening a different terminal and changing the bash profile.
我尝试通过键入打开 bash
I tried opening bash by typing
/bin/bash
我成功地打开了另一个终端,但我仍然无法访问任何常规的 unix 命令.我仍然无法打开 vi 或 nano 来删除导致问题的行.
and I was successfully able to open another terminal but I still don't have access to any of the regular unix commands. I still wasn't able to open vi or nano to remove the line that is causing the problem.
我尝试下载新的终端应用程序,但没有成功.
I tried downloading a new terminal application without any luck.
我尝试打开隐藏文件,以便我可以通过运行以下命令使用文本编辑器更改文件:
I tried turning on hidden files so that I can just change the file with a text editor by running the following command:
defaults write com.apple.finder AppleShowAllFiles TRUE
但由于我的终端不工作,所以也不起作用.
but since my terminal isn't working that didn't work either.
我该如何修理我的电脑.
How can I fix my computer.
虽然这与 stackoverflow 无关,但修复起来也很简单:
While this is offtopic for stackoverflow, it's also pretty simple to fix:
- 启动 Terminal.app.
重置
$PATH
:
$ export PATH=/bin:/usr/bin:/usr/local/bin
修复~/.bash_profile
:
$ vi ~/.bash_profile
或者你可以完全避免设置 $PATH
:
Or you can avoid setting $PATH
at all with:
$ /usr/bin/vi ~/.bash_profile