diff options
author | EuAndreh <eu@euandre.org> | 2022-10-28 20:46:20 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2022-10-28 20:52:53 -0300 |
commit | 491fe0987f73149236d50e64a4ee8a6f1ec2b5ed (patch) | |
tree | 7b0a4fafc462554062bc4a00b4bce233d9a5d66e /bin | |
parent | bin/gc: Add gc_vcs() step (diff) | |
download | dotfiles-491fe0987f73149236d50e64a4ee8a6f1ec2b5ed.tar.gz dotfiles-491fe0987f73149236d50e64a4ee8a6f1ec2b5ed.tar.xz |
bin/gc: Support TYPE argument
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/gc | 50 |
1 files changed, 38 insertions, 12 deletions
@@ -4,7 +4,7 @@ set -eu usage() { cat <<-'EOF' Usage: - gc + gc [TYPE] gc -h EOF } @@ -15,15 +15,29 @@ help() { Options: -h, --help show this message + TYPE what to do GC on (default: all): + - guix + - nohup + - trash + - tmpdir + - docker + - email + - vcs + Free disk space system-wide. Examples: - Just run it: + Just run it, for all: $ gc + + + Cleanup tmpdir: + + $ gc tmpdir EOF } @@ -106,17 +120,29 @@ gc_vcs() { } +gc_all() { + set -x + gc_guix + gc_nohup + gc_trash + gc_tmpdir + gc_docker + gc_email + gc_vcs + set +x +} + +TYPE="${1:-all}" +CMD=gc_"$TYPE" +if ! command -v "$CMD" >/dev/null; then + printf 'Invalid TYPE: "%s".\n\n' "$TYPE" >&2 + usage >&2 + exit 2 +fi + + BEFORE="$(disk)" -set -x -gc_guix -gc_nohup -gc_trash -gc_tmpdir -gc_docker -gc_email -gc_vcs -wait -set +x +"$CMD" AFTER="$(disk)" printf 'Disk space:\n' |