@ -6,79 +6,56 @@
#
#
# Get the prefix or use the default.
# Get the prefix or use the default.
zstyle -s ':omz:module:gnu-utils' prefix '_gnu_utils_prefix' ||
zstyle -s ':omz:module:gnu-utils' prefix '_gnu_utils_p' || _gnu_utils_p = 'g'
_gnu_utils_prefix = 'g'
# Check for the presence of GNU Core Utilities.
# Check for the presence of GNU Core Utilities.
if ( ( ! $+commands[ ${ _gnu_utils_prefix } dircolors] ) ) ; then
if ( ( ! ${ +commands[ ${ _gnu_utils_p } dircolors ] } ) ) ; then
return 1
return 1
fi
fi
function _gnu-utils-hash-commands {
_gnu_utils_cmds = (
emulate -L zsh
# Coreutils
'[' 'base64' 'basename' 'cat' 'chcon' 'chgrp' 'chmod' 'chown'
local cmds
'chroot' 'cksum' 'comm' 'cp' 'csplit' 'cut' 'date' 'dd' 'df'
local cmd
'dir' 'dircolors' 'dirname' 'du' 'echo' 'env' 'expand' 'expr'
local pcmd
'factor' 'false' 'fmt' 'fold' 'groups' 'head' 'hostid' 'id'
'install' 'join' 'kill' 'link' 'ln' 'logname' 'ls' 'md5sum'
cmds = (
'mkdir' 'mkfifo' 'mknod' 'mktemp' 'mv' 'nice' 'nl' 'nohup' 'nproc'
# Coreutils
'od' 'paste' 'pathchk' 'pinee' 'pr' 'printenv' 'printf' 'ptx'
'[' 'base64' 'basename' 'cat' 'chcon' 'chgrp' 'chmod' 'chown'
'pwd' 'readlink' 'realpath' 'rm' 'rmdir' 'runcon' 'seq' 'sha1sum'
'chroot' 'cksum' 'comm' 'cp' 'csplit' 'cut' 'date' 'dd' 'df'
'sha224sum' 'sha256sum' 'sha384sum' 'sha512sum' 'shred' 'shuf'
'dir' 'dircolors' 'dirname' 'du' 'echo' 'env' 'expand' 'expr'
'sleep' 'sort' 'split' 'stat' 'stty' 'sum' 'sync' 'tac' 'tail'
'factor' 'false' 'fmt' 'fold' 'groups' 'head' 'hostid' 'id'
'tee' 'test' 'timeout' 'touch' 'tr' 'true' 'truncate' 'tsort'
'install' 'join' 'kill' 'link' 'ln' 'logname' 'ls' 'md5sum'
'tty' 'uname' 'unexpand' 'uniq' 'unlink' 'uptime' 'users' 'vdir'
'mkdir' 'mkfifo' 'mknod' 'mktemp' 'mv' 'nice' 'nl' 'nohup' 'nproc'
'wc' 'who' 'whoami' 'yes'
'od' 'paste' 'pathchk' 'pinee' 'pr' 'printenv' 'printf' 'ptx'
'pwd' 'readlink' 'realpath' 'rm' 'rmdir' 'runcon' 'seq' 'sha1sum'
# The following are not part of Coreutils but installed separately.
'sha224sum' 'sha256sum' 'sha384sum' 'sha512sum' 'shred' 'shuf'
'sleep' 'sort' 'split' 'stat' 'stty' 'sum' 'sync' 'tac' 'tail'
# Binutils
'tee' 'test' 'timeout' 'touch' 'tr' 'true' 'truncate' 'tsort'
'addr2line' 'ar' 'c++filt' 'elfedit' 'nm' 'objcopy' 'objdump'
'tty' 'uname' 'unexpand' 'uniq' 'unlink' 'uptime' 'users' 'vdir'
'ranlib' 'readelf' 'size' 'strings' 'strip'
'wc' 'who' 'whoami' 'yes'
# Findutils
# The following are not part of Coreutils but installed separately.
'find' 'locate' 'oldfind' 'updatedb' 'xargs'
# Binutils
# Libtool
'addr2line' 'ar' 'c++filt' 'elfedit' 'nm' 'objcopy' 'objdump'
'libtool' 'libtoolize'
'ranlib' 'readelf' 'size' 'strings' 'strip'
# Miscellaneous
# Findutils
'getopt' 'grep' 'indent' 'sed' 'tar' 'time' 'units' 'which'
'find' 'locate' 'oldfind' 'updatedb' 'xargs'
)
# Libtool
# Wrap GNU utilities in functions.
'libtool' 'libtoolize'
for _gnu_utils_cmd in " ${ _gnu_utils_cmds [@] } " ; do
_gnu_utils_pcmd = " ${ _gnu_utils_p } ${ _gnu_utils_cmd } "
# Miscellaneous
if ( ( ${ +commands[ ${ _gnu_utils_pcmd } ] } ) ) ; then
'getopt' 'grep' 'indent' 'sed' 'tar' 'time' 'units' 'which'
eval "
)
function ${ _gnu_utils_cmd } {
'${commands[${_gnu_utils_pcmd}]}' \" \$ @\"
for cmd in " $cmds [@] " ; do
}
#
"
# This method allows for builtin commands to be primary but it's
# lost if hash -r or rehash -f is executed. Thus, those two
# functions have to be wrapped.
#
pcmd = " ${ _gnu_utils_prefix } ${ cmd } "
if ( ( $+commands[ $pcmd ] ) ) ; then
builtin hash " $cmd " = " $commands [ $pcmd ] "
fi
done
return 0
}
_gnu-utils-hash-commands
function hash {
if ( ( $+argv[ ( er) -r] ) ) || ( ( $+argv[ ( er) -f] ) ) ; then
builtin hash " $@ "
_gnu-utils-hash-commands
else
builtin hash " $@ "
fi
fi
}
done
function rehash {
unset _gnu_utils_{ p,cmds,cmd,pcmd}
hash -r " $@ "
}