Step 1: Create a shell script that logs your install command before executing it. Something like this (warning: this is barely tested, and I have no idea what it will do if you pass it arguments involving fancy shenanigans like quotes and pipes and whatnot):
#!/bin/sh
prog=apt-get # or 'yum' or 'emerge' or whatever
echo "$prog $*" >> ~/install-commands.txt
$prog $*
Step 2: Alias your shell script to the name of whatever command you're replacing.
Step 3: Install software as usual. Each time you install a package, it will be logged in install-commands.txt.
Step 4: When you need to reinstall your programs, run `bash install-commands.txt`
(Also note: if you use a GUI to install software, you can't easily do stuff like this. Now you know why the command line is better.)