7

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?

1 Answer 1

21

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
2
  • 1
    Will this escape everything correctly?
    – gerrit
    Mar 1, 2013 at 20:59
  • Do you have something special in mind? For example no problem with alias weired='echo \\$hello'.
    – mpy
    Mar 1, 2013 at 21:03

You must log in to answer this question.

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