Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I've accidentally overwritten my ~/.bash_profile file.

Does anyone have a "sample" one I could copy, or know where I might be able to find one?

share|improve this question
    
A good time to mention that GitHub is an excellent place to store your dotfile customizations. For an example of how to do this see: sursolid.com/managing-home-dotfiles-with-git-and-github –  Ian C. Sep 26 '11 at 13:19
2  
Tip: Use Time Machine to make regular backups of your files so you can recover them if accidentally deleted or edited. The single best investment you can make in your computer is a backup plan. –  Chris Page Sep 26 '11 at 14:43
    
Just FYI, I don't think os x has a "default" .bash_profile. –  Robert S Ciaccio Sep 26 '11 at 20:32
2  
This really could have been answered by google ("sample bash_profile"). The 3rd hit provides a rather massively complete sample: tldp.org/LDP/abs/html/sample-bashrc.html –  cksum Sep 26 '11 at 21:28
add comment

5 Answers 5

Search for dot_files in Google or Github if you like a sample one.

If you like to restore it, you could try to get it from your TimeMachine backup (if present)

share|improve this answer
2  
or any other backup - if no backup start producing one now before doing anything else –  Mark Sep 26 '11 at 12:41
add comment

Unfortunately this is what revision control is for. There is no way to undo modifications, while deletes through finder are actually moves to the trash.

Use TimeMachine in the future. Aside from this, it will also give you piece of mind when your current hard drive dies. I know people facing this problem now and if they only invested $30-$50 into a backup hdd, the problems would not happen. I recommend you just learn from this and back up using timemachine periodically.

Github as mentioned by Ian C is a great place to back your dotfiles, also you can find dotfiles from others'. Version control to the rescue here, don't know how many times it saved me, but definitely more than I can remember. The advantage of TimeMachine is that it also does version control, problem is that its stored by snapshot time, not logical version.

Good luck.

share|improve this answer
add comment

By default, hidden files cannot be seen in Time Machine or Finder. If you are trying to restore your file from a backup but can't see the .bash_profile file listed, you need to enable the display of hidden files in Finder.

To enable the display of hidden files type the following two commands into Terminal

defaults write com.apple.Finder AppleShowAllFiles YES
killall Finder

Now perform your restore from your backup of your home directory.

To make these files hidden again, type the following commands into Terminal

defaults write com.apple.Finder AppleShowAllFiles NO
killall Finder

Note: Case is important in the commands above.

share|improve this answer
1  
Or just open Terminal and use cp –  patrix Sep 27 '11 at 11:21
add comment

If you can't use Terminal to access your ~/.bash_profile (e.g. it's corrupted) you can use BBEdit or any other GUI editor that can open files from a location and open your corrupted file in order to fix it.

BTW. if you know the location and name of any hidden file, this method can be used to open it (assuming it is a text based file).

share|improve this answer
add comment

There is a backup located at:

/etc/skel/.bash_profile

Just copy it over your current file.

share|improve this answer
    
Might be worth to add that this is the standard template, so any changes the user made to his local .bash_profile will not be reflected in it. –  patrix Feb 18 at 12:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.