You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
2.6 KiB
99 lines
2.6 KiB
13 years ago
|
#
|
||
|
# Provides for the interactive usage of GNU Coreutils on BSD systems.
|
||
|
#
|
||
|
# Authors:
|
||
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||
|
#
|
||
13 years ago
|
|
||
|
# Get the prefix or use the default.
|
||
13 years ago
|
zstyle -s ':omz:module:gnu-utils' prefix '_gnu_utils_prefix' ||
|
||
13 years ago
|
_gnu_utils_prefix='g'
|
||
14 years ago
|
|
||
13 years ago
|
# Check for the presence of GNU Core Utilities.
|
||
13 years ago
|
if (( ! $+commands[${_gnu_utils_prefix}dircolors] )); then
|
||
13 years ago
|
return 1
|
||
|
fi
|
||
14 years ago
|
|
||
13 years ago
|
function _gnu-utils-hash-commands {
|
||
13 years ago
|
emulate -L zsh
|
||
13 years ago
|
|
||
|
local cmds
|
||
13 years ago
|
local cmd
|
||
13 years ago
|
local pcmd
|
||
14 years ago
|
|
||
13 years ago
|
cmds=(
|
||
13 years ago
|
# Coreutils
|
||
13 years ago
|
'[' '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'
|
||
14 years ago
|
|
||
13 years ago
|
# The following are not part of Coreutils but installed separately.
|
||
|
|
||
|
# Binutils
|
||
13 years ago
|
'addr2line' 'ar' 'c++filt' 'elfedit' 'nm' 'objcopy' 'objdump'
|
||
|
'ranlib' 'readelf' 'size' 'strings' 'strip'
|
||
13 years ago
|
|
||
|
# Findutils
|
||
13 years ago
|
'find' 'locate' 'oldfind' 'updatedb' 'xargs'
|
||
13 years ago
|
|
||
|
# Libtool
|
||
13 years ago
|
'libtool' 'libtoolize'
|
||
13 years ago
|
|
||
|
# Miscellaneous
|
||
13 years ago
|
'getopt' 'grep' 'indent' 'sed' 'tar' 'time' 'units' 'which'
|
||
13 years ago
|
)
|
||
14 years ago
|
|
||
13 years ago
|
for cmd in "$cmds[@]"; do
|
||
13 years ago
|
#
|
||
|
# 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.
|
||
|
#
|
||
13 years ago
|
pcmd="${_gnu_utils_prefix}${cmd}"
|
||
|
if (( $+commands[$pcmd] )); then
|
||
|
builtin hash "$cmd"="$commands[$pcmd]"
|
||
14 years ago
|
fi
|
||
13 years ago
|
done
|
||
14 years ago
|
|
||
13 years ago
|
return 0
|
||
|
}
|
||
13 years ago
|
_gnu-utils-hash-commands
|
||
13 years ago
|
|
||
13 years ago
|
function hash {
|
||
|
if (( $+argv[(er)-r] )) || (( $+argv[(er)-f] )); then
|
||
|
builtin hash "$@"
|
||
13 years ago
|
_gnu-utils-hash-commands
|
||
13 years ago
|
else
|
||
13 years ago
|
builtin hash "$@"
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
function rehash {
|
||
|
hash -r "$@"
|
||
|
}
|
||
|
|
||
|
# A sensible default for ls.
|
||
|
alias ls='ls --group-directories-first'
|
||
|
|
||
|
if zstyle -t ':omz:alias:ls' color; then
|
||
|
if [[ -f "$HOME/.dir_colors" ]]; then
|
||
13 years ago
|
eval "$(dircolors "$HOME/.dir_colors")"
|
||
13 years ago
|
else
|
||
13 years ago
|
eval "$(dircolors)"
|
||
13 years ago
|
fi
|
||
13 years ago
|
alias ls="$aliases[ls] --color=auto"
|
||
|
else
|
||
|
alias ls="$aliases[ls] -F"
|
||
14 years ago
|
fi
|
||
14 years ago
|
|