Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I had a ton of aliases defined and I use them all the time. I have a terminal session open now in which all the aliases are valid and working. However, the .bash_aliases file in which they were defined has been deleted. How can I expand or recover my aliases from my terminal session?

share|improve this question
up vote 20 down vote accepted

Simply use the command alias which prints out all definitions in a format bash can read in again:

$ alias
alias second='again'
alias test='hello'

So to recover, simply use

$ alias > .bash_aliases
share|improve this answer
1  
Will this escape everything correctly? – gerrit Mar 1 '13 at 20:59
    
Do you have something special in mind? For example no problem with alias weired='echo \\$hello'. – mpy Mar 1 '13 at 21:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .