I made an echo command to my .bash_aliases file and erased all of my aliases, except the test alias. However, I still have a session open that has the aliases loaded (into the tcl?). Can I retrieve them from this session?
Asked
Active
Viewed 1,935 times
17
-
9What if you just type `alias`? It will show what you have defined. – fedorqui Jul 23 '14 at 15:04
-
3Your next question is now required to be about setting up a backup system. :-/ – derobert Jul 23 '14 at 16:06
-
2Your next task, as soon as you've recreated your `.bash_aliases`, is to [set up version control for your dot files](http://unix.stackexchange.com/questions/1875/tips-for-putting-under-source-control). – Gilles 'SO- stop being evil' Jul 23 '14 at 23:02
-
@Gilles even better: http://unix.blogoverflow.com/2014/04/getting-started-with-version-controlled-configurations/ – strugee Jul 24 '14 at 05:26
2 Answers
15
Easy trick
for alias in $(compgen -a); do type $alias; done
dchirikov
- 3,818
- 2
- 15
- 18
-
4
-
1Combine this with redirection to a file (`$alias` > `.bash_aliases`, maybe with some file regexes to get it to the right place in the file) and you don't have to type it back into the original file yourself. (That is, if you haven't already typed it in.) – trysis Jul 23 '14 at 18:12
-
1While this works, I don't see the benefit over just using 'alias'. The format isn't particularly useful by comparison. – moopet Jul 24 '14 at 08:01