prezto_config/modules/gnu-utils/init.zsh

62 lines
1.9 KiB
Bash
Raw Normal View History

2012-02-01 05:37:51 +01:00
#
# Provides for the interactive usage of GNU Coreutils on BSD systems.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
2012-04-02 18:00:34 +02:00
# Get the prefix or use the default.
zstyle -s ':omz:module:gnu-utils' prefix '_gnu_utils_p' || _gnu_utils_p='g'
2011-02-03 23:25:45 +01:00
# Check for the presence of GNU Core Utilities.
if (( ! ${+commands[${_gnu_utils_p}dircolors]} )); then
return 1
fi
2011-02-03 23:25:45 +01:00
_gnu_utils_cmds=(
# Coreutils
'[' 'base64' 'basename' 'cat' 'chcon' 'chgrp' 'chmod' 'chown'
'chroot' 'cksum' 'comm' 'cp' 'csplit' 'cut' 'date' 'dd' 'df'
'dir' 'dircolors' 'dirname' 'du' 'echo' 'env' 'expand' 'expr'
'factor' 'false' 'fmt' 'fold' 'groups' 'head' 'hostid' 'id'
'install' 'join' 'kill' 'link' 'ln' 'logname' 'ls' 'md5sum'
'mkdir' 'mkfifo' 'mknod' 'mktemp' 'mv' 'nice' 'nl' 'nohup' 'nproc'
'od' 'paste' 'pathchk' 'pinee' 'pr' 'printenv' 'printf' 'ptx'
'pwd' 'readlink' 'realpath' 'rm' 'rmdir' 'runcon' 'seq' 'sha1sum'
'sha224sum' 'sha256sum' 'sha384sum' 'sha512sum' 'shred' 'shuf'
'sleep' 'sort' 'split' 'stat' 'stty' 'sum' 'sync' 'tac' 'tail'
'tee' 'test' 'timeout' 'touch' 'tr' 'true' 'truncate' 'tsort'
'tty' 'uname' 'unexpand' 'uniq' 'unlink' 'uptime' 'users' 'vdir'
'wc' 'who' 'whoami' 'yes'
# The following are not part of Coreutils but installed separately.
# Binutils
'addr2line' 'ar' 'c++filt' 'elfedit' 'nm' 'objcopy' 'objdump'
'ranlib' 'readelf' 'size' 'strings' 'strip'
# Findutils
'find' 'locate' 'oldfind' 'updatedb' 'xargs'
# Libtool
'libtool' 'libtoolize'
# Miscellaneous
'getopt' 'grep' 'indent' 'sed' 'tar' 'time' 'units' 'which'
)
# Wrap GNU utilities in functions.
for _gnu_utils_cmd in "${_gnu_utils_cmds[@]}"; do
_gnu_utils_pcmd="${_gnu_utils_p}${_gnu_utils_cmd}"
if (( ${+commands[${_gnu_utils_pcmd}]} )); then
eval "
function ${_gnu_utils_cmd} {
'${commands[${_gnu_utils_pcmd}]}' \"\$@\"
}
"
fi
done
unset _gnu_utils_{p,cmds,cmd,pcmd}