bash 如何在 Mac 上恢复 .bash_profile?我的 unix 终端都没有工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21067625/
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
How to restore .bash_profile on a mac? None of my unix terminal are working
提问by j.jerrod.taylor
I added something to my bash_profile while trying to add Playframework to my path and something got messed up badly.
我在尝试将 Playframework 添加到我的路径时向我的 bash_profile 添加了一些东西,但有些东西搞砸了。
I added the following line to my .bash_profile
我将以下行添加到我的 .bash_profile
export PATH=$PATH:the path to my play excitable
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 thisthread on SuperUser that suggested opening a different terminal and changing the bash profile.
然后我保存了所有内容并重新启动了我的终端。我不能再从我的终端做任何事情。我无法 cd 进入任何目录,我再也找不到 java,我无法打开 vi 或 nano。我在 SuperUser 上发现了这个线程,它建议打开一个不同的终端并更改 bash 配置文件。
I tried opening bash by typing
我尝试通过键入打开 bash
/bin/bash
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.
我成功地打开了另一个终端,但我仍然无法访问任何常规的 unix 命令。我仍然无法打开 vi 或 nano 来删除导致问题的行。
I tried downloading a new terminal applicationwithout 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.
我该如何修理我的电脑。
回答by trojanfoe
While this is offtopic for stackoverflow, it's also pretty simple to fix:
虽然这是 stackoverflow 的题外话,但修复起来也很简单:
- Start Terminal.app.
Reset
$PATH
:$ export PATH=/bin:/usr/bin:/usr/local/bin
Fix
~/.bash_profile
:$ vi ~/.bash_profile
- 启动 Terminal.app。
重置
$PATH
:$ export PATH=/bin:/usr/bin:/usr/local/bin
修复
~/.bash_profile
:$ vi ~/.bash_profile
Or you can avoid setting $PATH
at all with:
或者您可以完全避免设置$PATH
:
$ /usr/bin/vi ~/.bash_profile