1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-05-20 10:53:23 -07:00
rc/sh/ify

24 lines
545 B
Bash
Executable File

#!/usr/bin/sh
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
ify() { ### @-
### pipe one command through another, so you can still pass arguments to the former.
###
### this is mainly useful for aliases. 99% of the time you'll use this with `less`.
###
### ```
### $ alias ll="ify less ls -ACX --group-directories-first --color=force"
### $ ll /etc
### ```
[ $# -ge 2 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
local ex="$1"
shift
"$@" | "$ex"
}
[ -n "${preload+-}" ] || ify "$@"