1
0
Fork 0

Allow different prefixes for gnu-utils

pull/85/head
Colin Hebert 13 years ago
parent 8ad3ebd88f
commit 1e3efc2b42

@ -5,57 +5,54 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# Check for the presence of GNU Core Utilities.
if (( ! $+commands[gdircolors] )); then
return 1
fi
function _gnu-utils-hash-commands { function _gnu-utils-hash-commands {
emulate -L zsh emulate -L zsh
local gcmds local cmds
local gcmd
local cmd local cmd
local prefix
zstyle -a ':omz:plugin:gnu-utils' prefix 'prefix' || prefix='g'
gcmds=( gcmds=(
# Coreutils # Coreutils
'g[' 'gbase64' 'gbasename' 'gcat' 'gchcon' 'gchgrp' 'gchmod' 'gchown' '[' 'base64' 'basename' 'cat' 'chcon' 'chgrp' 'chmod' 'chown'
'gchroot' 'gcksum' 'gcomm' 'gcp' 'gcsplit' 'gcut' 'gdate' 'gdd' 'gdf' 'chroot' 'cksum' 'comm' 'cp' 'csplit' 'cut' 'date' 'dd' 'df'
'gdir' 'gdircolors' 'gdirname' 'gdu' 'gecho' 'genv' 'gexpand' 'gexpr' 'dir' 'dircolors' 'dirname' 'du' 'echo' 'env' 'expand' 'expr'
'gfactor' 'gfalse' 'gfmt' 'gfold' 'ggroups' 'ghead' 'ghostid' 'gid' 'factor' 'false' 'fmt' 'fold' 'groups' 'head' 'hostid' 'id'
'ginstall' 'gjoin' 'gkill' 'glink' 'gln' 'glogname' 'gls' 'gmd5sum' 'install' 'join' 'kill' 'link' 'ln' 'logname' 'ls' 'md5sum'
'gmkdir' 'gmkfifo' 'gmknod' 'gmktemp' 'gmv' 'gnice' 'gnl' 'gnohup' 'gnproc' 'mkdir' 'mkfifo' 'mknod' 'mktemp' 'mv' 'nice' 'nl' 'nohup' 'nproc'
'god' 'gpaste' 'gpathchk' 'gpinee' 'gpr' 'gprintenv' 'gprintf' 'gptx' 'od' 'paste' 'pathchk' 'pinee' 'pr' 'printenv' 'printf' 'ptx'
'gpwd' 'greadlink' 'grealpath' 'grm' 'grmdir' 'gruncon' 'gseq' 'gsha1sum' 'pwd' 'readlink' 'realpath' 'rm' 'rmdir' 'runcon' 'seq' 'sha1sum'
'gsha224sum' 'gsha256sum' 'gsha384sum' 'gsha512sum' 'gshred' 'gshuf' 'sha224sum' 'sha256sum' 'sha384sum' 'sha512sum' 'shred' 'shuf'
'gsleep' 'gsort' 'gsplit' 'gstat' 'gstty' 'gsum' 'gsync' 'gtac' 'gtail' 'sleep' 'sort' 'split' 'stat' 'stty' 'sum' 'sync' 'tac' 'tail'
'gtee' 'gtest' 'gtimeout' 'gtouch' 'gtr' 'gtrue' 'gtruncate' 'gtsort' 'tee' 'test' 'timeout' 'touch' 'tr' 'true' 'truncate' 'tsort'
'gtty' 'guname' 'gunexpand' 'guniq' 'gunlink' 'guptime' 'gusers' 'gvdir' 'tty' 'uname' 'unexpand' 'uniq' 'unlink' 'uptime' 'users' 'vdir'
'gwc' 'gwho' 'gwhoami' 'gyes' 'wc' 'who' 'whoami' 'yes'
# The following are not part of Coreutils but installed separately. # The following are not part of Coreutils but installed separately.
# Binutils # Binutils
'gaddr2line' 'gar' 'gc++filt' 'gelfedit' 'gnm' 'gobjcopy' 'gobjdump' 'addr2line' 'ar' 'c++filt' 'elfedit' 'nm' 'objcopy' 'objdump'
'granlib' 'greadelf' 'gsize' 'gstrings' 'gstrip' 'ranlib' 'readelf' 'size' 'strings' 'strip'
# Findutils # Findutils
'gfind' 'glocate' 'goldfind' 'gupdatedb' 'gxargs' 'find' 'locate' 'oldfind' 'updatedb' 'xargs'
# Libtool # Libtool
'glibtool' 'glibtoolize' 'libtool' 'libtoolize'
# Miscellaneous # Miscellaneous
'ggetopt' 'ggrep' 'gindent' 'gsed' 'gtar' 'gtime' 'gunits' 'gwhich' 'getopt' 'grep' 'indent' 'sed' 'tar' 'time' 'units' 'which'
) )
for gcmd in "$gcmds[@]"; do for cmd in "$cmds[@]"; do
# #
# This method allows for builtin commands to be primary but it's # This method allows for builtin commands to be primary but it's
# lost if hash -r or rehash -f is executed. Thus, those two # lost if hash -r or rehash -f is executed. Thus, those two
# functions have to be wrapped. # functions have to be wrapped.
# #
if (( $+commands[$gcmd] )); then if (( $+commands[$prefix$cmd] )); then
builtin hash "$gcmd[2,-1]"="$commands[$gcmd]" builtin hash "$cmd"="$commands[$prefix$cmd]"
fi fi
done done
@ -81,9 +78,9 @@ alias ls='ls --group-directories-first'
if zstyle -t ':omz:alias:ls' color; then if zstyle -t ':omz:alias:ls' color; then
if [[ -f "$HOME/.dir_colors" ]]; then if [[ -f "$HOME/.dir_colors" ]]; then
eval "$(gdircolors "$HOME/.dir_colors")" eval "$(dircolors "$HOME/.dir_colors")"
else else
eval "$(gdircolors)" eval "$(dircolors)"
fi fi
alias ls="$aliases[ls] --color=auto" alias ls="$aliases[ls] --color=auto"
else else

Loading…
Cancel
Save