Completely restore root and home folder after many problems with Macports and Homebrew
All those files look normal to me, including the hidden ones.  Unless you had/have an active backup from a date before your changes, there is no way to "restore" it back to an exact state before "opening Terminal". (That made me chuckle)  That being said...

Should be possible to back up user data (your home folder entirely), erase your hard drive (from the Recovery partition if necessary), reinstall OS X, and move your user data back.  The sacrifice there is any system-level applications/preferences that you've set.  However, it's likely the Homebrew/MacPorts settings on the system-level that are causing your issues.

It really boils down to how much time you want to spend digging through documentation, trying different things, changing different settings to get your system back to the way you want it.  If you have the time and patience, it will be much more rewarding and (possibly) less impactful to your OS X environment.

On the flip side, it's sometimes easier (and more time-effective) to just "nuke and pave" as we call it. :)