Apple - How do I find what packages I've installed via terminal?
Since OS X has no package manager, anything you install would have been manual, through MacPorts or through Installer.
If you want a list of the binaries your terminal has access to, you can run the following commands to check the most common spots, and output the result as a text file:
touch ~/Binaries.txt
ls /usr/bin > ~/Binaries.txt
ls /usr/sbin >> ~/Binaries.txt
ls /usr/local/bin >> ~/Binaries.txt
ls /usr/local/sbin >> ~/Binaries.txt
ls /opt/local/bin >> ~/Binaries.txt
ls /opt/local/sbin >> ~/Binaries.txt
Alternatively, if you just want to get the packages installed by MacPorts, run the following (this is probably the one you want):
touch ~/MacPorts.txt
port installed > ~/MacPorts.txt
And for Homebrew:
touch ~/HomeBrew.txt
brew list > ~/HomeBrew.txt
And finally, for all packages installed by Installer
touch ~/InstalledPackages.txt
pkgutil --packages > ~/InstalledPackages.txt
To restore, for example, your MacPorts ports from the list generated above, use the following:
port install $(cat ~/MacPorts.txt)