Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 19 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
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.