How to restore .bash_profile on a mac? None of my unix terminal are working [closed]

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 00:54:54

问题


I added something to my bash_profile while trying to add Playframework to my path and something got messed up badly.

I added the following line to my .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 this thread on SuperUser that suggested opening a different terminal and changing the bash profile.

I tried opening bash by typing

/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.

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.


回答1:


While this is offtopic for stackoverflow, it's also pretty simple to fix:

  1. Start Terminal.app.
  2. Reset $PATH:

    $ export PATH=/bin:/usr/bin:/usr/local/bin
    
  3. Fix ~/.bash_profile:

    $ vi ~/.bash_profile
    

Or you can avoid setting $PATH at all with:

$ /usr/bin/vi ~/.bash_profile


来源:https://stackoverflow.com/questions/21067625/how-to-restore-bash-profile-on-a-mac-none-of-my-unix-terminal-are-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!