From 3ab4e41230d8e3ff64e5cb3054c5185945615dd6 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 8 Dec 2023 18:27:09 -0300 Subject: etc/sh/rc: Replace "clean" alias with clean(1) utility --- bin/clean | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/vcs | 4 ++++ etc/sh/rc | 1 - 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100755 bin/clean diff --git a/bin/clean b/bin/clean new file mode 100755 index 0000000..889af8d --- /dev/null +++ b/bin/clean @@ -0,0 +1,70 @@ +#!/bin/sh +set -eu + + +usage() { + cat <<-'EOF' + Usage: + clean + clean -h + EOF +} + +help() { + cat <<-'EOF' + + + Options: + -h, --help show this message + + + Clean the project and list the leftover files. + + + Examples: + + Just run it: + + $ clean + EOF +} + + +for flag in "$@"; do + case "$flag" in + (--) + break + ;; + (--help) + usage + help + exit + ;; + (*) + ;; + esac +done + +while getopts 'h' flag; do + case "$flag" in + (h) + usage + help + exit + ;; + (*) + usage >&2 + exit 2 + esac +done +shift $((OPTIND - 1)) + + +if [ -e dev.mk ]; then + F='Makefile' +else + F='dev.mk' +fi + +make -sf"$F" clean +vcs clean diff --git a/bin/vcs b/bin/vcs index 7c9bce6..b51cf33 100755 --- a/bin/vcs +++ b/bin/vcs @@ -165,6 +165,10 @@ git_ls() { git ls-files } +git_clean() { + git clean -nffdx +} + usage() { cat <<-'EOF' diff --git a/etc/sh/rc b/etc/sh/rc index 2c8e93c..8abef18 100644 --- a/etc/sh/rc +++ b/etc/sh/rc @@ -211,7 +211,6 @@ alias info='info --init-file "$XDG_CONFIG_HOME"/info/infokey' alias wget='wget --hsts-file="$XDG_STATE_HOME"/wget-hsts' alias tmux='tmux -f "$XDG_CONFIG_HOME"/tmux/tmux.conf' -alias clean='make -s clean && git clean -nffdx' alias flush='sync && echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null' alias kal='khal calendar today `LANG=en.UTF-8 date +%A`' -- cgit v1.2.3