Keep only compressed logs of installed packages (for Gentoo's portage system)
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


(C) Martin Väth <>
This project is under a BSD type license, meaning that you can do almost
anything with it except removing my name.

With Gentoo, it is a good idea to keep the install logs
of all installed packages.
In case something goes wrong, a "grep" in these logs is sometimes very handy.

However, if you set PORT_LOGDIR in your make.conf, you soon have also
thousands of logs of obsolete packages, because each emerge (successful or not)
and also each unmerge (even fast unmerge) produces a logfile.

The purpose of this project is to eliminate all logs except for the
newest installation logs for the actually installed packages;
the used ones are compressed using xz, lzma, bzip2, or gzip,
and selected ones (from /etc/logclean.conf) are even shortened.
Moreover, by default all color sequences are removed.

This script takes care in a similar way about your files in
/var/log/elogs (cf. the ELOG feature of portage) and of your files in
/var/log/notices (cf. the unofficial enotice script).

This script can also cleanup your temporary installation directories in
/var/tmp/portage (do not use this in a cron job if portage might be running).

Finally, this script can also shorten the main portage logfile
/var/log/emerge.log so that only the actually installed packages are logged.
(You might want to keep these for usage with qlop or genlop).

This script is also offers option for a convenient usage from a cron job.

If you have installed app-portage/eix, this script will run slightly faster.

For installation, copy the content of bin/ with executable permission in your
path (perhaps /usr/bin/) and the (possible edited) content of etc/ to /etc/
To obtain support for zsh completion, you can copy the content of zsh/ to a
directory of zsh's $fpath (perhaps /usr/share/zsh/site-functions/).
There is also an ebuild in the mv overlay (which is available by layman).