Last active
January 8, 2022 17:40
-
-
Save joepvd/fa76322514895617fac2241377c4c1ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Love you, GNU. But got a bit tired of this conversation pattern: | |
# | |
# % ln -h | |
# ln: invalid option -- 'h' | |
# Try 'ln --help' for more information. | |
# | |
# Don't worry. I fixed you for me. | |
# | |
# Eternally yours, | |
# | |
# github.com/joepvd | |
for util in base64 basename cat chmod chroot cksum comm cp csplit cut dd \ | |
dirname env factor fmt groups head hostid hostname id install join \ | |
ln logname md5sum mkdir mkfifo mknod mktemp mv nice nohup nproc \ | |
paste pathchk printenv ptx readlink realpath rm rmdir runcon seq \ | |
shuf sleep split stat stdbuf stty sum sync tac tail tee timeout tr \ | |
tsort tty uname unexpand uniq unlink uptime users wc who whoami yes \ | |
$(: and non coreutils :) \ | |
date | |
do function $util { | |
if [[ "$1" == -h ]] | |
then command "$0" --help | |
else command "$0" "$@" | |
fi | |
} | |
done; unset util |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a little tip I stumbled across: The
eval
isn't necessary. Zsh allows you to define a function with a name taken from a variable and$0
can substitute for the uses of$util
in the function body.Also,
ls
probably shouldn't be in that list unless you add a check for$# == 1
becausels
uses-h
to mean--human-readable
and, if someone aliasesls=ls -h
to default to human-friendly filesizes, you'll get every attempt to invokels
being changed tols --help
instead.